Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved


Chapter 13 OAuth Server : Token Request API

Token Request API
To request an access token from the OAuth server, use the following API:
Name
/access_token
Description
Processes an access token request.
Access Token Request
The client makes a request to the token endpoint by sending the following parameters using the application/x-www-form-urlencoded format with a character encoding of UTF-8 in the HTTP POST request:
Required, if the redirect_uri parameter was included in the authorization request. The value must match the redirect_uri value sent in the authorization request.
Access Token Request Example
To request an access token for the authorization code flow, the client makes the following HTTP POST request using TLS:

 
POST /asg/oauth2/access_token HTTP/1.1
Host: server.example.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA
&redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb

 
Access Token Response
If the access token request is valid and authorized, the authorization server issues an access token and an optional refresh token. The refresh token may be returned only for authorization code flow.
Access Token Response Example
The following is a successful response:

 
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache
 
{
"access_token":"2YotnFZFEjr1zCsicMWpAA",
"token_type":"example",
"expires_in":3600,
"refresh_token":"tGzv3JOkF0XG5Qx2TlKWIA",
"example_parameter":"example_value"
}

 
Access Token Request Error
If the request client authentication failed or is invalid, the authorization server returns an error response. The authorization server responds with an HTTP 400 status code (unless specified otherwise) and includes the following parameters with the response:
The following table lists the error codes for the error returned for an invalid token request::
Access Token Error Example
The following is an example of the error response for an access token request:

 
HTTP/1.1 400 Bad Request
Content-Type: application/json;charset=UTF-8
Cache-Control: no-store
Pragma: no-cache
 
{
"error":"invalid_request"
}

Copyright © Cloud Software Group, Inc. All Rights Reserved
Copyright © Cloud Software Group, Inc. All Rights Reserved