diff --git a/src/Http/Controllers/AccessTokenController.php b/src/Http/Controllers/AccessTokenController.php index 3898261..5a78e24 100644 --- a/src/Http/Controllers/AccessTokenController.php +++ b/src/Http/Controllers/AccessTokenController.php @@ -41,8 +41,20 @@ public function issueToken(ServerRequestInterface $request) $payload = json_decode($response->getBody()->__toString(), true); if (isset($payload['access_token'])) { - $tokenId = $this->jwt->parse($payload['access_token'])->getClaim('jti'); + /* @deprecated the jwt property will be removed in a future Laravel Passport release */ + $token = $this->jwt->parse($payload['access_token']); + if (method_exists($token, 'getClaim')) { + $tokenId = $token->getClaim('jti'); + } else if (method_exists($token, 'claims')) { + $tokenId = $token->claims()->get('jti'); + } else { + throw new \RuntimeException('This package is not compatible with the Laravel Passport version used'); + } + $token = $this->tokens->find($tokenId); + if (!$token instanceof Token) { + return $response; + } if ($token->client->firstParty() && LumenPassport::$allowMultipleTokens) { // We keep previous tokens for password clients