From Bright Pattern Documentation
< 5.3:Host-and-services-management-api-specification
Revision as of 04:09, 29 May 2024 by BpDeeplTranslateMaintenance (talk | contribs) (Updated via BpDeleteTranslateTags script)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
• 5.19 • 5.2 • 5.3 • 5.8

Request an Access Token

This method requests an access token.

URL

http[s]://<host>:<port>/configapi/v2/oauth/token

Parameters

Parameter Required? Description
grant_type Required The value must be client_credentials.
client_id Required Login ID
client_secret Required User API secret

Example of Request

The following HTTP POST requests an access token for the https://example.com web service. The client_id identifies the user on behalf of the application of the access token.

POST /configapi/v2/oauth/token HTTP/1.1
Host: example.com
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id=client-id&client_secret=qkDwDJlDfig2IpeuUZYKH1Wb8q1V0ju6sILxQQqhJ&tenant=example.com

Access Token Response

A success response for requesting an access token contains a JSON OAuth 2.0 response with the following parameters.

Parameters

Parameter Description
access_token The requested access token. The calling application can use this token to authenticate to the receiving service.
token_type Indicates the token type value. The only supported type is Bearer. For more information about bearer tokens, see The OAuth 2.0 Authorization Framework: Bearer Token Usage (RFC 6750).
expires_in How long the access token is valid (in seconds).

Example of Response

The following example shows a success response to a request for an access token to a web service.

{
"access_token":"eyJhbGciOiJSUzI1NiI5q9Jgt...6HznsvPWy7UP3MINA",
"token_type":"Bearer",
"expires_in":"3599",
}

Use the Access Token to Access the Resource

Now when an access_token is successfully acquired, it is possible to use the token in requests to Web APIs by including it in the Authorization header. RFC 6750 explains how to use bearer tokens in HTTP requests to access protected resources.

Sample Request

GET /data HTTP/1.1
Host: example.com

Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbW4t

< Previous | Next >