Skip to content

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

Closed
@murilolivorato

Description

@murilolivorato
  • 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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions