mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-02 19:51:03 +05:30
39 lines
2.1 KiB
Markdown
39 lines
2.1 KiB
Markdown
---
|
|
layout: default
|
|
title: AccessTokenRepositoryInterface documentation
|
|
permalink: /access-token-repository-interface/
|
|
---
|
|
|
|
# Access Token Repository Interface
|
|
|
|
## getNewToken() : AccessTokenEntityInterface
|
|
|
|
This method should return an implementation of `\League\OAuth2\Server\Entities\AccessTokenEntityInterface`. You can use the following traits to help you implement the required methods from that interface:
|
|
|
|
* `League\OAuth2\Server\Entities\Traits\AccessTokenTrait`
|
|
* `League\OAuth2\Server\Entities\Traits\EntityTrait`
|
|
* `League\OAuth2\Server\Entities\Traits\TokenEntityTrait`
|
|
|
|
Note in version `5.0.x` this method has a number of parameters passed in. As of version `5.1.0` these parameters have been removed because they were unnecessary (see issue #553).
|
|
|
|
## persistNewAccessToken() : void
|
|
|
|
When a new access token is created this method will be called. You don't have to do anything here but for auditing you probably want to.
|
|
|
|
The access token entity passed in has a number of methods you can call which contain data worth saving to a database:
|
|
|
|
* `getIdentifier() : string` this is randomly generated unique identifier (of 80+ characters in length) for the access token.
|
|
* `getExpiryDateTime() : \DateTime` the expiry date and time of the access token.
|
|
* `getUserIdentifier() : string|null` the user identifier represented by the access token.
|
|
* `getScopes() : ScopeEntityInterface[]` an array of scope entities
|
|
* `getClient()->getIdentifier() : string` the identifier of the client who requested the access token.
|
|
|
|
JWT access tokens contain an expiry date and so will be rejected automatically when used. You can safely clean up expired access tokens from your database.
|
|
|
|
## revokeAccessToken() : void
|
|
|
|
This method is called when a refresh token is used to reissue an access token. The original access token is revoked a new access token is issued.
|
|
|
|
## isAccessTokenRevoked() : boolean
|
|
|
|
This method is called when an access token is validated by the resource server middleware. Return `true` if the access token has been manually revoked before it expired. If the token is still valid return `false`. |