Skip to main content

Authentication

Your agency authenticates with the OAuth 2.0 client-credentials flow. Stafflion issues a client ID and a client secret for each environment. Exchange them for an access token, then send the token on every request.

Token request​

Call the token endpoint with your client ID, client secret, the audience of the environment, and grant_type set to client_credentials.

Using the token​

Send the token in the Authorization header of every request:

Authorization: Bearer <access_token>

The token expires after expires_in seconds (86400, 24 hours). Request a new token when it expires. Do not log the client secret or the token.

Headers​

HeaderValueUsed in
Content-Typeapplication/jsonToken request, events
AuthorizationBearer <access_token>Events, synchronized shifts API
Acceptapplication/jsonSynchronized shifts API

Request and responses​

curl --request POST \
--url https://auth.stafflion.com/oauth/token \
--header 'Content-Type: application/json' \
--data '{
"audience": "https://staging.stafflion.com/api/v1",
"client_id": "YOUR_STAGING_CLIENT_ID",
"grant_type": "client_credentials",
"client_secret": "YOUR_STAGING_CLIENT_SECRET"
}'

Responses​

200 OK​

OK

Access token

{
"expires_in": 86400,
"token_type": "Bearer",
"access_token": "ACCESS_TOKEN"
}

401 Invalid client ID or secret​

Invalid client ID or secret. Illustrative body, confirm against staging.

Invalid client

{
"error": "invalid_client",
"error_description": "Invalid client credentials."
}

422 Validation failed​

Validation failed. A required field is missing.

Missing client_id

{
"message": "The given data was invalid.",
"errors": {
"client_id": [
"The client_id field is required."
]
}
}