Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Rulian's avatar

Passport password grant is not working

Setting up passport on brand new laravel 5.7 app Got thru the install steps, I have my server keys and my client id/secrets setup. I register a user, and use passports oauth/token endpoint to validate the email/password I registered.

I then post that info to get an access_token back in Postman

curl -X POST \
  http://myapp.abc/oauth/token \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Postman-Token: c4aaf369-70e3-4690-af04-5728a75c16ab' \
  -H 'cache-control: no-cache' \
  -d 'grant_type=password&client_id=1&client_secret=....&[email protected]&password=mypassword&scope='

I recieve a response that looks correct {"token_type":"Bearer","expires_in":31536000,"access_token":"e.....k"}

However, using that token to a route behind auth:api middleware

curl -X GET \
  http://myapp.abc/api/protected \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer e...k' \
  -H 'cache-control: no-cache'

I get{"error":"Unauthenticated."} error

Looking down the stack, its not even trying to validate whether or not my user token is correct, it fails on trying to validate the token signature

League\OAuth2\Server\AuthorizationValidators\BearerTokenValidator@69
 if ($token->verify(new Sha256(), $this->publicKey->getKeyPath()) === false) {

which tries to validate the signature of the token on 
Lcobucci\JWT\Signer\Rsa@47
return openssl_verify($payload, $expected, $key, $this->getAlgorithm()) === 1;

the issue is openssl_verify($payload, $expected, $key, $this->getAlgorithm()) return 0

It is finding my oauth public key and correctly pulling in the info. I tried on my OSX and a fresh install of Homestead thinking it may be openssl issue but no luck.

Anyone have any issue, am I not suppose to use the access_token from that validate auth credentials to make get requests?

0 likes
1 reply
nagra's avatar

@rulian I'm having the same issue in Laravel 8, did you find a solution for this? 😕.

Please or to participate in this conversation.