createAccessToken

@POST(value = accessToken)
abstract suspend fun createAccessToken(@Query(value = grant_typegrantType: String, @Query(value = redirect_uriredirectUri: String, @Query(value = codecode: String, @Query(value = refresh_tokenrefreshToken: String, @Body() accessTokenRequestDto: AccessTokenRequestDto): Response<AccessTokenResponseDto>

Obtain an Access Token Allows a client to use its credentials to obtain an access token, to swap an authorization grant for an access token, or to swap a refresh token for a new access token. There are two types of access tokens - user tokens and client tokens. &lt;br/&gt;&lt;br/&gt;A client token authenticates a specific client, e.g. your architecture and servers. client tokens can be used to access any resources owned by the client, such as general information on users your client has created. Client tokens are also required to register new users or make requests on their behalf such as the user posting a receipt. &lt;br/&gt;&lt;br/&gt;A user token authenticates a specific user to our system, e.g. Jane Doe of Winnipeg, Manitoba. A user token will be required if you want to access specific data about a user, such as the details of that user&#39;s documents. &lt;br/&gt;&lt;br/&gt;Token expiry information is in the &#x60;expires_in&#x60; and &#x60;refresh_expires_in&#x60; fields. &lt;br/&gt;&lt;br/&gt;You can also retrieve the expiration times for user and client access tokens using the user GET endpoint, &#x60;/users/:userID&#x60;, and the clientInfo GET endpoint, &#x60;/clientInfo&#x60;, respectively. &lt;br/&gt;&lt;br/&gt;No matter which kind of access token is being requested, the client MUST include their Client Key and Client Secret as the username and password, respectively, in the HTTP Authorization header, on top of providing required parameters below. &lt;br/&gt;&lt;br/&gt;This can be accomplished by setting a &#39;basic&#39; authentication header using the Client Key and Client Secret as username and password like shown below: &lt;br/&gt;&lt;br/&gt;&#x60;Authorization: &#39;Basic base64(ClientKey:ClientSecret)&#39;&#x60; &lt;br/&gt;&lt;br/&gt;The access token is currently always a bearer token, which should be sent in the &#39;Authorization&#39; header in the format &#39;Bearer accessToken&#39;. &lt;br/&gt;&lt;br/&gt;In the future, other token types may also be used, so please check the &#x60;token_type&#x60; provided in the response. &lt;br/&gt;&lt;br/&gt;For an example, please refer to &lt;a href&#x3D;&#39;./apiref/demo.html#step_six&#39;&gt;&#39;Authentication Step Six&#39; of the jQuery Demo&lt;/a&gt;. &lt;br/&gt;&lt;br/&gt;The response also returns a &#x60;token_id&#x60;. This can not be used for authenticating regular requests, but is required for using our query parameter based signature method. Responses:

  • 200: Success. The access token was created successfully.

  • 400: Bad Request. This will occur if you omit a required parameter, or if you provide an invalid value for a required parameter. It can also occur if you put in the wrong Redirect URI, for example, if you put one that doesn't match what you provided when you made the authorization grant request.

  • 401: Unauthorized. This will occur if the client key/secret you have provided is invalid.

Return

AccessTokenResponseDto

Parameters

grantType

This is the type of authentication the client is presenting for its access-token. &lt;br/&gt;&lt;br/&gt;If the client is looking for a client-token, then this should be set to &#39;client_credentials&#39;. &lt;br/&gt;&lt;br/&gt;If the client is looking to swap an authorization grant for an access token, this should be set to &#39;authorization_code&#39; &lt;br/&gt;&lt;br/&gt;If the client is looking to swap a refresh_token for a new access token, this should be set to &#39;refresh_token&#39;

redirectUri

If the client is swapping an authorization code for an access token, then this argument is required. If you are just obtaining a client token directly, you do not need to provide a redirect_uri. This must be the same redirect_uri that was provided to the authorizationGrant endpoint, and must also match the redirect_uri which was registered with your client when you received your client credentials.

code

If the client is swapping an authorization code for an access token, then this argument is required. If you are just obtaining a client token directly, you do not need to provide a code. This parameter is the authorization_code which you obtained when you used the &#x60;/authorizationGrant&#x60; endpoint.

refreshToken

If the client is swapping a refresh_token for an access token, then this argument is required. Otherwise, this parameter should be omitted. This parameter is the refresh_token which you obtained when you last used the &#x60;/accessToken&#x60; endpoint.

accessTokenRequestDto

Access Token Request