API Authentication

To make requests to the API a Bearer JWT token will need to be generated and attached to every API request.

Client Credentials

A Client ID and a Client Secret will be provided to you during Partner and Scanning devices on boarding.

Keep the Client Secret stored securely

Using the provided Client ID and Client Secret make a request to https://auth.prismlabs.tech/oauth/token to generate a Bearer token to be used when making request to Prism API.

Sandbox vs. Production

The url to generate the access token will always be https://auth.prismlabs.tech/oauth/token.

The audience value will change depending on environment:

  • https://sandbox-api.prismlabs.tech/ when using sandbox credentials

  • https://api.prismlabs.tech/ when using production credentials

curl --location --request POST 'https://auth.prismlabs.tech/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=client_credentials' \
--data-urlencode 'client_id=PARTNER_CLIENT_ID' \
--data-urlencode 'client_secret=PARTNER_CLIENT_SECRET' \
--data-urlencode 'audience=https://sandbox-api.prismlabs.tech/'
{
    "access_token": "GENERATED_ACCESS_TOKEN",
    "scope": "AUTHORIZED_SCOPES",
    "expires_in": 86400,
    "token_type": "Bearer"
}

Extract and cache the access_token until it expires for requests to the API. Failure to cache may result in additional costs or revoking access to Prism API.

From now on, every time you make a call to our API endpoints attach the cached access_token as a Bearer token to the Authorization header. 'Authorization: Bearer GENERATED_ACCESS_TOKEN'

Below you can find sample code for an example of creating a new user via the /users endpoint:

curl --location --request POST 'https://sandbox-api.prismlabs.tech/users' \
--header 'Accept: application/json;v=1' \
--header 'Authorization: Bearer GENERATED_ACCESS_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
    "sex": "male",
    "region": "north_america",
    "birthYear": 1950,
    "weight": {
        "value": 275,
        "unit": "lb"
    }
}'

Note: that the Accept header requires a version number application/json;v=1

Last updated