我在我的项目中使用Laravelpassport。 我需要使用刷新令牌创建令牌,但刷新令牌无法创建
public function login(Request $request, User $admin)
{
$valiDate = $this->validate($request, [
'email' => 'required|email|exists:admins|max:40',
'password' => 'required|min:5|string',
//'lang'=>'required'
]);
if(!Auth::attempt($valiDate)){
return response()->json([ 'message' => 'Unauthorized' ], 401);
}
$user = $request->user();
$tokenResult = $user->createToken('Personal Access Token');
$token = $tokenResult->token;
$token->save();
return response()->json([
// 'email'=>$valiDate['email'],
'access_token' => $tokenResult->accessToken,
'token_type' => 'Bearer',
'expires_at' => Carbon::parse( $tokenResult->token->expires_at )->toDateTimeString()
]);
}