Grant authentication token

Retrieve a JWT-compliant access token for use with all other endpoints.


📘 All tokens currently expire after 24 hours (86,400 seconds), but we suggest refreshing tokens every 12 hours (43,200 seconds).

Here's an example of using the returned token in an API call:

curl \
  --url "https://api.ocrolus.com/v1/books" \
  --oauth2-bearer "eyJhbGciOiJ...2hUye_4CpIvQ"

See our guide on using API credentials for more details.

This endpoint is OAuth 2.0-compliant. A successful response from this endpoint adheres to the structure given in RFC 6749, section 5.1, while a failed response adheres to the structure given in section 5.2. As a consequence, you can use this endpoint in OAuth 2.0 clients and libraries without needing to explicitly call it in your own code.

post/oauth/token

Request

  • Base URL
    https://auth.ocrolus.com
  • URL
    https://auth.ocrolus.com/oauth/token
  • Auth
    none declared

Request body

grant_type'client_credentials' required

The OAuth 2.0 grant type for the returned token. Must have a value of client_credentials, as we don't offer other grant types at this time.

audience'https://api.ocrolus.com/'

The domain in which the token will be used. We currently only support the value of https://api.ocrolus.com/ (including the trailing /).

client_idstring required

The client ID that was generated from the Ocrolus Dashboard.

client_secretstring required

The client secret associated with the client ID that was generated from the Ocrolus Dashboard.

Example request

{
  "grant_type": "client_credentials",
  "audience": "https://api.ocrolus.com/",
  "client_id": "CLIENT_ID_EXAMPLE",
  "client_secret": "CLIENT_SECRET_EXAMPLE"
}

Response

Success

access_tokenstring

A JWT-compliant access token for use with all other endpoints.

token_typestring

The type of access token received.

expires_ininteger

The amount of time before the provided access token becomes invalid.

Example response

{
  "access_token": "eyJz93a...k4laUWw",
  "token_type": "Bearer"
}

Changes

No recorded changes to this operation across all 1 revision of this API.