Back to top

Step 2 — Get access and refresh tokens

Last updated December 21st, 2023

Now you may call Knox authorization server token endpoint to get access token (short lived — 10 minutes) and refresh token (long lived — 24 hours) in exchange for the authorization code (short lived — 1 minute). For more details, please check Knox OAuth2 Authorization Server API. You would need to update refresh token before it expires as explained in “Step 4” (below).

Getting an access token using the authorization code request example:

--location '' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'client_id={OAUTH2_CLIENT_ID}' \
--data-urlencode 'client_secret={OAUTH2_CLIENT_SECRET}' \
--data-urlencode 'redirect_uri={REDIRECT_URL_USED_IN_AUTHZ_CODE_REQ}' \
--data-urlencode 'code_verifier={PKCE_CODE_VERIFIER}' \
--data-urlencode 'code={AUTHORIZATION_CODE}'

You receive the access and refresh tokens in the format below. The value of the expires_in key denotes the number of seconds that the access token is valid for.

  "expires_in": 599,

You need an active access token every time you make a Knox cloud API call.

Is this page helpful?