Answer the question
In order to leave comments, you need to log in
How to make tokens in Laravel 5.3 Passport with dots?
I upgraded my Laravel project from 5.2 to 5.3 in order to use Laravel Passport and use it to authorize by a token through api.
A few weeks later, I'm still suffering with an authorization error (Unauthenticated error). After tens of hours of studying the Internet on this issue, I started debugging the code of the package itself and this is what I realized:
My problem is revealed in this file \vendor\lcobucci\jwt\src\Parser.php, namely in this method:
protected function splitJwt($jwt)
{
if (!is_string($jwt)) {
throw new InvalidArgumentException('The JWT string must have two dots');
}
$data = explode('.', $jwt);
if (count($data) != 3) {
throw new InvalidArgumentException('The JWT string must have two dots');
}
return $data;
}
$this->user->createToken($this->user->id.' Access Token')->accessToken;
Answer the question
In order to leave comments, you need to log in
I found something wrong
I tried to show the token to the user via $user->tokens()->first()->id
But it's not a token, it's an ID of some entity in the database
Just similar to
the token We get the real code of the token from $this- >user->createToken($name)->accessToken
And this is the value that needs to be returned and shown
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question