Access tokens

Best practices for handling OAuth tokens

In OAuth, access tokens are opaque strings that allow a client to access the protected resource.

The exact format of access and refresh tokens is left out of scope of OAuth specification, allowing the authorization server to use the representation that fits their needs the best. Because of that, clients should not assume any particular implementation, and should treat access and refresh tokens as opaque bits of information. Clients can store tokens obtained from the authorization server, and supply them in requests to resource servers — but they must not peek inside the text content of the tokens.

❗️

Access tokens are opaque

Do not rely on the content of access and refresh tokens in the implementation of your client. Their format is not guaranteed, and can be changed without notice. This can break the interoperability of your application with Pleo.

Token Introspection

Clients can use the token introspection endpoint to to obtain information about access tokens. Clients can use this endpoint to check the validity of access tokens, and find out other information such as which resource and which scopes are associated with the token.

EnvironmentToken introspection endpoint URI
Staginghttps://auth.staging.pleo.io/oauth/token/introspect
Productionhttps://auth.pleo.io/oauth/token/introspect

Introspection request

Token introspection endpoint uses basic client authentication, using client identifier and client secret.

Client calls the introspection endpoint using as HTTP POST request, with parameters sent as application/x-www-form-urlencoded data.

ParameterDescription
token[REQUIRED] The string value of the token.
token_type_hint[OPTIONAL] A hint about the type of the token submitted for introspection. Either access_token or refresh_token

Introspection response

The server responds with a JSON object in application/json format with the following top-level members.

MemberDescription
activeBoolean indicator of whether or not the presented token is currently active.
subUniversally Unique Identifier (UUID) of a resource that the access token has authorised.
urn:pleo:params:oauth:subject_urnUnique Resource Name (URN) of a resource that the access token has authorised.
expUNIX timestamp indicating when this token will expire.
iatUNIX timestamp indicating when this token was originally issued.
client_idClient identifier for the OAuth 2.0 client that requested this token.
audService-specific string identifier or list of string identifiers representing the intended audience for this token.
issString representing the issuer of this token.
jtiString identifier for the token.

Example

In this example, a client with a client identifier s6BhdRkqt3 and a client secret gX1fBat3bV, issues a token introspection request, to introspect an access token with the value of mF_9.B5f-4.1JqM.

POST /oauth/token/introspect HTTP/1.1
Host: auth.staging.pleo.io
Accept: application/json
Content-Type: application/x-www-form-urlencoded
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW

token=mF_9.B5f-4.1JqM

Introspection response:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "active": true,
  "client_id": "s6BhdRkqt3",
  "sub": "b6e0abaf-0c69-4443-b59b-908cb6aabcce",
  "urn:pleo:params:oauth:subject_urn": "urn:pleo:company:b6e0abaf-0c69-4443-b59b-908cb6aabcce",
  "aud": "https://external.staging.pleo.io",
  "iss": "pleo.staging",
  "iat": 1720706356,
  "exp": 1720707256,
}