Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passport changes, get user information ( id, name ) with the personal access_token it is not working #1590

Closed
murilolivorato opened this issue Oct 28, 2022 · 2 comments

Comments

@murilolivorato
Copy link

  • Passport Version: 11.3
  • Laravel Version: 9.19
  • PHP Version: 8.1.11
  • Database Driver & Version: mysql:8.0.1

Description:

I can see that passport class had some changes -
#1464

before , in my AuthServiceProvider class , I used to add this code -

Passport::routes();

and now I dont add any more with those changes .
I dont know If I have to add in other place, the passport routes .

well . but my question is , I have a personal token that I get like this -

first I create the access token -

php artisan passport:client --personal

then I log in -

$user = User::find(1);
return $user->createToken('the_persona_ access_client_name')->accessToken;

so it returns a access token .

with this token I make a request to get the user information , like this -

request to - myap.com/api/user-info
header - Bearer my_token_goes_here

in the user info Controller -

public function user_info(Request $request)
    {
 return ['user' => auth()->user()];
}

it is returning null -

{
    "user": null
}

It is not returning any more my user .

Steps To Reproduce:

@driesvints
Copy link
Member

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

@murilolivorato
Copy link
Author

sorry @driesvints , my mistake .
I forgot to add this in the route -

Route::get('/user', function () {
    //
})->middleware('auth:api');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants