Get an Access Token

Requests to the CAM REST API require an access token. There are two ways to obtain an access token: username/password method and refresh token method.

The returned access_token from either method is supplied for each call to the API. Typically, the calling application uses the first form to obtain the initial access token (and an associated refresh token). The second form is used to get a new access token when the initial token expires. This enables the application to require a username/password only once, and then use the refresh token for subsequent access token requests.

Username/password Method

Make an HTTP POST request to the Oauth2/token endpoint using the API key and credentials with the following request body:

                                {
    "grant_type": "password",
    "client_id": <api-key>",
    "username": "<user-name>",
    "password": "<password>",
    "scope": "cam",
}

                            

The response body from this request returns the access token and a refresh token that can be used to obtain subsequent access tokens.

                                {
    "access_token": "<access-token>",
    "expires_in": "<token-expiration-in-seconds>",
    "refresh_token": "<refresh-token>",
}

                            

Refresh Token Method

Make an HTTP POST request to the Oauth2/token endpoint using the API key and refresh token returned by the initial access token request with the following request body:

                                {
    "grant_type": "refresh_token",
    "client_id": "<api-key>",
    "refresh-token": "<refresh-token>",
}

                            

The response body from this request provides the access token:

                                {
    "access_token": "<access-token>",
    "expires_in": "<token-expiration-in-seconds>",
    "refresh_token": "<refresh-token>",
}