OAuth 2.0 REST API Authorization
Overview
There is a REST API provided by AndApp. In order to call the REST API, an Access Token is necessary, which gets with the OAuth 2.0 procedures. Here is descriptions about the following.
- Supported Client Authentication
- URI for each environment of each endpoint
- Supported Authorization Grant types
Supported Client Authentication
The following Client Authentication method is supported:
| Client authentication method | Description |
|---|---|
| client_secret_basic | The client_id and the client_secret issued by the Developer Dashboard in advance are used. This Client Authentication method is to do a BASIC authentication with the client_id as a username and the client_secret as a password. |
An example to authenticate the Client with the client_id: 16443766213 and the client_secret: RE5yRx4Q20atUmUiJFrEEssuK47r5DjSV7cn84iAsyO is like the following.
POST /1.0.0/token HTTP/1.1
Host: sb-connect.andapp.jp:443
Authorization: Basic MTY0NDM3NjYyMTM6UkU1eVJ4NFEyMGF0VW1VaUpGckVFc3N1SzQ3cjVEalNWN2NuODRpQXN5Tw==
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&scope=notificationMessage%3AanyUsers%3Acreate
URI for each environment of each endpoint
This section describes the URI for each environment of each endpoint.
Token Endpoint
| environment | URI |
|---|---|
| sandbox | https://sb-connect.andapp.jp/1.0.0/token |
| Production environment | https://connect.andapp.jp/1.0.0/token |
Supported Authorization Grant types
In order to get the Access Token, you must get some Authorization Grant. Grant flow that are currently supported is the following:
- Client Credentials Grant Flow
Client Credentials Grant Flow
It shows the sequence diagram of the Client Credentials Grant Flow in the figure below.
The Token Request with the "application/x-www-form-urlencoded" as the Content-Type and the supported Client Authentication must be sent with POST method. The parameters of the Token Request are shown below.
| property | required | description |
|---|---|---|
| grant_type | true | Specify the client_credentials. |
| scope | false | It specifies the scopes which want to get. If nothing is specified, all scopes allowed in advance are applied. See the reference of each REST API for the available scope. |
A format of the Token Response is specified by the Content-Type as the "application/json". The parameters to be returned in the Token Response are shown below.
property | type | description |
|---|---|---|
| token_type | string | Fixed value: "Bearer". |
| access_token | string | The Access Token is returned. |
| scope | string | The scopes are returned. |
| expires_in | integer | The expiration of the Access Token, indicated the validity period from the issue date and time in seconds. |
An example of Token Request / Response is shown below.
POST /1.0.0/token HTTP/1.1
Host: sb-connect.andapp.jp:443
Authorization: Basic MTY0NDM3NjYyMTM6UkU1eVJ4NFEyMGF0VW1VaUpGckVFc3N1SzQ3cjVEalNWN2NuODRpQXN5Tw==
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials&scope=notificationMessage%3AanyUsers%3Acreate
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-cache
Pragma: no-cache
{
"token_type": "Bearer",
"access_token": "eyj...",
"scope": "notificationMessage:anyUsers:create",
"expires_in": 1800
}
Change log
- 2016/07/28
- Since the Token Endpoint of URI has been changed, it has been corrected.
- 2016/06/06
- Created