0
votes

Hello To All I'm facing problem for using passport Oauth2 Authentication in laravel 5.4, I am working on project where I define two routes 1. For login through API http://localhost:8000/api/login from Which, I got a response as Access Token. 2. Another for get user details http://localhost/api/user and I am getting the user details.

But When I deploy my App to server and try to Hit the above two URL in Postman I am getting the access token but While tried to access the user with the generated access token. It send me error of Unauthenticated.

Do I need to generate passport key in server with php artisan passport:keys

1

1 Answers

0
votes

Yes you'll need the encryption keys on the server as well:

php artisan passport:keys

// or with new installations
php artisan passport:install

Also ensure you're using the correct auth guard, auth:api, when accessing the user:

// middleware
Route::group(['middleware' => ['auth:api'])->(...)

// and with the user helper
auth('api')->user()