createAuthorizationCode
Description
Creates authorization code that can be subsequently used to obtain an access token. Used in Authorization Code flow.
Syntax
oauth2.createAuthorizationCode (service_key, client, uri, scope, user_context)
Parameters
| Parameter | Type | Description |
| service_key | string | The id of the OAuth 2.0 protected service definition |
| client | client object | A client object containing at least the client_id |
| uri | uri object | URI data used to redirect to after issuing authorization code. If redirect URI validation is mandated by the API administrator, this will be validated against the pre-registered redirect URI |
| scope | string | Optional space-delimited list of scope identifiers (provider-defined) |
| user_context | string |
Optional provider-defined user context identifier |
| response_type | string |
Optional on the mashery cloud OAuth API, Required on Mashery Local OAuth API. Value of 'code' |
Return Value
{
"code": <authorization code: string>
"uri": <redirection data: uri object>
}
Errors (in addition to standard JSON-RPC errors)
|
JSON-RPC Code |
Error Message |
Description |
|
-2001 |
An OAuth related error has occurred |
An error has occurred pertaining to the OAuth operation. Please check the corresponding structure in the error object for specific details. |
Sample Requests and Responses
Sample Request (Ordered Parameters)
{
"method":"oauth2.createAuthorizationCode",
"params":[
"rmeqcgpw3zu2y47y9bs8vs2h",
{
"client_id":"tkr7f25gd6452zy8rjsf7bwd"
},
{
"redirect_uri":"https:\/\/client.example.com\/cb"
},
null,
"ghdjg74hfkshge76rhgfjg7wsmnxhd",
"code"
],
"id":1
}
Sample Request (Named Parameters)
{
"jsonrpc":"2.0",
"method":"oauth2.createAuthorizationCode",
"params":{
"service_key":"rmeqcgpw3zu2y47y9bs8vs2h",
"client":{
"client_id":"tkr7f25gd6452zy8rjsf7bwd"
},
"uri":{
"redirect_uri":"https:\/\/client.example.com\/cb"
},
"scope":null,
"user_context":"ghdjg74hfkshge76rhgfjg7wsmnxhd",
"response_type":"code" },
"id":1
}
Sample Response
{
"result":{
"code":"ks02mfhc67wqnmcl",
"uri":{
"redirect_uri":"https:\/\/client.example.com\/cb?code=ks02mfhc67wqnmcl",
"state":""
}
},
"error":null,
"id":1
} Docs Navigation
- API Documentation Portal
- IO Docs Definition
- Mashery API Documentation
- Mashery 3.0 API Guide
- Mashery 2.0 API Guide
- OAuth Supporting Methods
- Examples
- JSON RPC
- Authentication
- API Objects
- Fetching Objects
- Query Language
- Creating Objects
- Updating Objects
- Validating Fields
- Deleting Objects
- Applications
- General Object Methods
- Members
- Packages
- Plans
- Package Keys
- Keys
- Developer Classes
- Services
- Roles
- Mashery 2.0 Reporting API Guide
- Event Trigger API
- Differences between Roles and Portal Access Groups
- Managing a Portal Access Group Using Mashery V2 or V3 API
- Mashery Reporting Event Post API Guide
- Tips and Tricks
- Your Portal
- API Traffic Manager
- I/O Docs WSDL requirements