Create Access Token Flow

post

/oauth2/rest/token

Request

Supported Media Types
Query Parameters
  • Identity Domain under which the token is being requested. This is an optional parameter if 'x-oauth-identity-domain-name' header parameter is provided.
Header Parameters
Form Parameters
  • User Assertion token.Mandatory parameter in case GrantType is JWT_BEARER.
  • Client Assertion token. This is mandatory if the Client Authentication mechanism is via the ClientAssertionToken. If this is passed, then the authorization header is not required.
  • Type of client assertion. This is mandatory if the Client Authentication mechanism is via the ClientAssertionToken. If this is passed, then the authorization header is not required.
    Allowed Values: [ "JWT_BEARER", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" ]
  • Authorization Code obtained.Mandatory parameter in case GrantType is AUTHORIZATION_CODE.
  • Grant Type for the Access Token Request
    Allowed Values: [ "CLIENT_CREDENTIALS", "AUTHORIZATION_CODE", "PASSWORD", "JWT_BEARER", "REFRESH_TOKEN" ]
  • Password of resource owner.Mandatory parameter in case GrantType is PASSWORD.
  • Redirect URI.Mandatory parameter in case GrantType is AUTHORIZATION_CODE.
  • Refresh Token played to generate the new Access Token.Mandatory parameter in case GrantType is REFRESH_TOKEN.
  • Scope requested in the Access Token. In case of REFRESH_TOKEN flows, defaulted to the values in the RefreshToken if not specified. In case JWT_BEARER flow access token requests UserInfo related scopes, supported scopes are UserInfo.me, UserInfo.email, UserInfo.profile, UserInfo.address or UserInfo.phone.
    Default Value: DefaultScope defined for Client
  • Username of resource owner. Mandatory parameter in case GrantType is PASSWORD.
Back to Top

Response

Supported Media Types

200 Response

Access Token was generated successfully
Body ()
Root Schema : AccessToken
Type: object
Show Source

400 Response

Bad Request
Body ()
Root Schema : ErrorCode
Type: object
Show Source
Back to Top

Examples

The following cURL command shows a sample request against the server for creating access tokens, with client_id=OAAClient and client_secret=xxx included in the request body.

Make sure to update the POST request URL, username, password, scope, client_id, and client_secret to match your specific setup.

Use Case 1: grant_type=PASSWORD

$ curl -i "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -H "X-OAUTH-IDENTITY-DOMAIN-NAME: OAADomain" --request POST http://oam01.example.com:xxxxx/oauth2/rest/token -d 'grant_type=PASSWORD&username=al.xxxx&password=xxx&scope=OAAResource.viewResource&client_id=OAAClient&client_secret=xxx'
Sample Response
{"access_token":"eyJrxxxxhHJc1GT4Q","token_type":"Bearer","expires_in":3600,"scope":"OAAResource.viewResource"}

Use Case 2: grant_type=CLIENT_CREDENTIALS

$ curl -i "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -H "X-OAUTH-IDENTITY-DOMAIN-NAME: OAADomain" --request POST http://oam01.example.com:xxxxx/oauth2/rest/token -d 'grant_type=CLIENT_CREDENTIALS&scope=OAAResource.viewResource&client_id=OAAClient&client_secret=xxx'
Sample Response
{"access_token":"eyJr<snip>eJNdLg1By-6LyuQ","token_type":"Bearer","expires_in":3600,"scope":"OAAResource.viewResource"}
Back to Top