AgriWebb API
API Reference

Token Exchange

POST
/oauth2/token

Exchange an authorization_code or a refresh_token for an access token.

Authentication

This endpoint requires the Client ID and Client Secret. The preferred way to send them is the Basic Auth strategy:

  • Join the Client ID and Client Secret with a single colon: "{ClientID}:{ClientSecret}"
  • Base64 encode this string: base64("{ClientID}:{ClientSecret}")
  • Construct the Authorization header: "Authorization: Basic {base64EncodedDigest}"

For example, the Client ID test-client-id and Client Secret test-secret-value give Authorization: Basic dGVzdC1jbGllbnQtaWQ6dGVzdC1zZWNyZXQtdmFsdWU=.

Alternatively, send them as client_id and client_secret in the body. If you send both the header and the body parameters, they must match.

Header Parameters

Authorization?string

The Client ID and Client Secret, as Basic {base64 of Client ID:Client Secret}. Send this, or client_id and client_secret in the body.

Request Body

application/x-www-form-urlencoded
  1. body
grant_type*"authorization_code"
Value in"authorization_code"
code*string

The authorisation code from the callback endpoint

Lengthlength <= 2048
redirect_uri?string

Required when more than one Redirect URL is registered for the client. When sent, it must match the redirect_uri of the Authorisation Request.

Formaturi
Lengthlength <= 2048
client_id?string

The Client ID, when authenticating with client_id and client_secret in the body instead of the Authorization header. If both are sent, they must match.

Lengthlength <= 64
client_secret?string

The Client Secret, when authenticating in the body instead of the Authorization header, which is preferred. If both are sent, they must match.

Lengthlength <= 2048

Response Body

The credentials for the integration. Store them securely: if they are lost or revoked, the user has to authorise the integration again.

application/json
  1. response
access_token*string

The access_token for this integration

token_type*"Bearer"

The type of the access_token

Value in"Bearer"
expires_in?number

The number of seconds before the access_token expires

refresh_token?string

The refresh_token for this integration

curl -X POST "https://example.com/oauth2/token" \  -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"}