POST oauth/access_token

Redeem access token for code

Response Codes

  • 200 – Successfully generated the access token
  • 400 – Missing or invalid parameters or something else wrong with the request.

Request Information

URI Parameters

None.

Body Parameters

AccessTokenRequest
NameDescriptionTypeAdditional information
grant_type

Grant type for getting the access token. authorization_code for getting access token for authorization code refresh_token for getting access token for refresh token

string

Required

client_id

Identifies the client that is making the request. The value passed in this parameter must exactly match the value in the registred Application.

string

Required

client_secret

The client secret that is created for the Application.

string

Required

code

Code that was returned from the OAuth Authorize step. Used when requesting token for exchange of authorization code. Set the grant_type to authorization_code.

string

None.

redirect_uri

If set, must be the same as the provided in the OAuth Authorize step.

string

None.

refresh_token

Refresh token that was returned in token response for exchange of code. Used when requesting token for exchange of refresh token code. Set the grant_type to refresh_token.

string

None.

non_expiring

Specify that the generated token should not expire

boolean

None.

Request Formats

application/json, text/json

Sample:
{
  "grant_type": "sample string-1",
  "client_id": "sample string-2",
  "client_secret": "sample string-3",
  "code": "sample string-4",
  "redirect_uri": "sample string-5",
  "refresh_token": "sample string-6",
  "non_expiring": true
}

application/xml, text/xml

Sample:
<AccessTokenRequest xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Sobralaen.Api.Models.OAuth">
  <client_id>sample string-2</client_id>
  <client_secret>sample string-3</client_secret>
  <code>sample string-4</code>
  <grant_type>sample string-1</grant_type>
  <non_expiring>true</non_expiring>
  <redirect_uri>sample string-5</redirect_uri>
  <refresh_token>sample string-6</refresh_token>
</AccessTokenRequest>

application/x-www-form-urlencoded

Sample:
grant_type=sample%20string-1&client_id=sample%20string-2&client_secret=sample%20string-3&code=sample%20string-4&redirect_uri=sample%20string-5&refresh_token=sample%20string-6&non_expiring=True

Response Information

Resource Description

Redeem access token for code
Access token

AccessTokenResult
NameDescriptionTypeAdditional information
refresh_token

Refresh token that can be used to request new access token if the old token is expired. If the token does not support refreshing or the access token lifetime is not set, this will be null. Returned only when request grant_type is authorization_code

string

None.

scope

Scope(s) that the user has selected in the Authorization step. Returned only when request grant_type is authorization_code

string

None.

token_type

Identifies the type of token returned. At this time, this field will always have the value Bearer.

string

Required

access_token

The token that must be sent to a API.

string

Required

expires_in

The lifetime in seconds of the access token. For example, the value "3600" denotes that the access token will expire in one hour from the time the response was generated. 0 is used when the token dows not expire.

integer

None.

valid_until

Token Valid until in Unix Time Stamp (Number of seconds since Unix Epoch on January 1st, 1970 at UTC).

integer

None.

Response Formats

application/json, text/json

Sample:
{
  "refresh_token": "sample string-1",
  "scope": "sample string-2",
  "token_type": "sample string-3",
  "access_token": "sample string-4",
  "expires_in": 5,
  "valid_until": 6
}

application/xml, text/xml

Sample:
<AccessTokenResult xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Sobralaen.Api.Models.OAuth">
  <access_token>sample string-4</access_token>
  <expires_in>5</expires_in>
  <token_type>sample string-3</token_type>
  <valid_until>6</valid_until>
  <refresh_token>sample string-1</refresh_token>
  <scope>sample string-2</scope>
</AccessTokenResult>