刷新Laravel护照中的令牌

时间:2020-02-20 08:37:38

标签: laravel

我在我的项目中使用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()
        ]);
}

0 个答案:

没有答案