May 18, 2018
0
Level 1
Why cannot i get the access token using in laravel passport
I am new to Laravel Passport. I am requesting the access token and it seems to work all fine.
$params = [
'grant_type' => 'password',
'client_id' => $this->client->id,
'client_secret' => $this->client->secret,
'username' => $request->email,
'password' => $request->password,
'scope' => '*'
];
$request->request->add($params);
$proxy = Request::create('/oauth/token', 'POST');
$accessToken = Route::dispatch($proxy);
return $accessToken;
But I also want to use get the authenticated user with the response so I do something like this
$proxy = Request::create('/oauth/token', 'POST');
$accessToken = Route::dispatch($proxy);
return [
'access_token' => $accessToken,
'auth_user' => auth()->user()
];
But the above code fails. In postman i get the following response that does not makes any sense to me
{
"access_token": {
"headers": {},
"original": {},
"exception": null
},
"auth_user": null
}
How do I get the authenticated user along with the access token
Please or to participate in this conversation.