Administering Mediator : Mediator Configurations : OAuth2 Inbound Configuration : The Service for Obtaining OAuth2 Access Tokens
The Service for Obtaining OAuth2 Access Tokens
Mediator hosts a REST service (pub.mediator.oauth2.getOAuth2AccessToken) to provide OAuth2 access tokens to consumers. Consumers can get access tokens by using the service URI and by specifying their client credentials. The service's input parameters are:
*client_id
*client_secret
*scope (optional). The scope value is the name of the virtual service. If the scope value is valid, Mediator obtains the access token. If no scope value is provided, Mediator provides the access token to the scope in which the client is allowed, and adds the scope to the response. To pass the scope, pass it in the request body.
Ways for Clients to Provide the Inputs
There are three ways in which a client can provide the inputs for this service:
*Provide inputs in the Basic authentication header (recommended).
The client can provide the client credentials (client_id and client_secret) in the Authorization header using the following form:
Authorization: Basic <base-64-encoded client_id:password, client_secret>
If you want to pass the scope, pass it in the request body.
*Provide JSON inputs for the service.
The client can send a JSON request to the service in the following form:
{
"client_id" : "",
"client_secret": "",
"scope" : ""
}
Note:  
The client must contain the header Content-type:application/json in the request.
*Provide inputs in the request body.
The OAuth2 specifications do not support sending the client credentials over the URL as URL-Encoded. However, you can send the client credentials in the request body using the following form:
client_id=<client_id>&client_secret=<client_secret>&scope=<scope>
Note:  
*The client must contain the header Content-type:application/x-www-form-urlencoded in the request.
*If a client provides the client_id and client_secret in both the Authorization header and the request body, the credentials given in the Authorization header are used.
Responses Returned to Clients
Following are sample responses that are returned to the client:
*Sample XML response:
<Response
xmlns="https://localhost/rest/pub.mediator.oauth2.getOAuth2AccessToken">
<access_token>db95b40095f31439a1cd8f411e64abe8</access_token>
<expires_in>3600</expires_in>
<token_type>Bearer</token_type>
</Response>
*Sample JSON response:
{
"access_token": "db95b40095f31439a1cd8f411e64abe8",
"token_type": "Bearer",
"expires_in": 3600
}
Copyright © 2015- 2017 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback