Token Exchange
POST /oauth2/token
Retrieve an access token for the API, either via exchanging an authorization_code
or by exchanging a refresh_token
.
Authentication
Authentication is required for this method, using Client ID and Client Secret via the Basic Auth strategy. Use the following methodology to create the required Authorization header:
- Create a string of Client ID and Client Secret concatenated by a single colon:
"{ClientID}:{ClientSecret}"
- Base64 encode this string:
base64("{ClientID}:{ClientSecret}")
- Construct the Authorization header:
"Authorization: Basic {base64EncodedDigest}"
For example, if we are to use the example credentials test-client-id
and test-secret-value
as the ClientID and ClientSecret we would get the following result: Authorization: Basic dGVzdC1jbGllbnQtaWQ6dGVzdC1zZWNyZXQtdmFsdWU=
Header Parameters
The only supported authorisation method is Basic ...
"refresh_token"
The authorisation code from the callback endpoint
length <= 2048
If the redirect_uri was provided earlier in the flow it is required to be passed through again here
uri
length <= 2048
A not recommended method for Client Authentication, prefer the header Authorization: Basic ...
length <= 64
A not recommended method for Client Authentication, prefer the header Authorization: Basic ...
length <= 2048
The refresh_token provided in a previous token exchange
length <= 2048
A token can be requested with a subset of the initially requested scopes
length <= 2048
Response Body
curl -X POST "https://auth.agriwebb.com/oauth2/token" \
-H "Authorization: string" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d 'grant_type=authorization_code&code=string'
{
"access_token": "string",
"token_type": "Bearer",
"expires_in": 0,
"refresh_token": "string"
}
{
"error": "invalid_request",
"error_description": "string",
"error_uri": "string"
}
{
"error": "invalid_request",
"error_description": "string",
"error_uri": "string"
}
{
"error": "invalid_request",
"error_description": "string",
"error_uri": "string"
}
{
"error": "invalid_request",
"error_description": "string",
"error_uri": "string"
}
{
"error": "invalid_request",
"error_description": "string",
"error_uri": "string"
}