I guess you could say that some part of the token is stored in the database.
The token returned is JWT (JSON Web Token). Encoded in it is information about the token, like its expiration time, the algorithm used to hash it, the token scopes and its ID (in the payload it's named jti
). That ID is what's stored in the oauth_access_tokens
table.
In this method in the \Laravel\Passport\PersonalAccessTokenFactory::findAccessToken
class you can see how Laravel is checking if the token is in the database:
/**
* Get the access token instance for the parsed response.
*
* @param array $response
* @return Token
*/
protected function findAccessToken(array $response)
{
return $this->tokens->find(
$this->jwt->parse($response['access_token'])->getClaim('jti')
);
}
If you get a valid token and paste it in this online tool you will see the structure of it. Here's how it looks:
Now, knowing the expected format of the payload, if you play around a bit with this information and the data you have in your oauth_access_tokens
(id, scope, creation and expiration date) you should be able to create a valid token.