アクセストークン発行
認証方式
AnyMotionでは、OAuthによる認証を行います。Client IDとClient Secretを用いて発行できるアクセストークンがAPIリクエストに必要となります。
Client IDとClient Secretは、AnyMotionポータルより取得できます。
POST /accesstokens
アクセストークンを発行します。
リクエスト
HTTPリクエスト
| POST https://api.customer.jp/v1/oauth/accesstokens
|
注意
他のエンドポイントとURLが異なることに注意してください。
リクエストヘッダー
リクエストヘッダー |
説明 |
Content-Type |
application/json |
リクエストボディ
プロパティ |
タイプ |
説明 |
必須 |
grantType |
String |
固定値
client_credentials を設定してください |
● |
clientId |
String |
ポータルより取得したClient ID |
● |
clientSecret |
String |
ポータルより取得したClient Secret |
● |
サンプルリクエスト
| {
"grantType": "client_credentials",
"clientId": "<Client ID>",
"clientSecret": "<Client Secret>"
}
|
レスポンス
レスポンスボディ
プロパティ |
タイプ |
説明 |
accessToken |
String |
アクセストークン |
tokenType |
String |
トークンタイプ |
expiredIn |
String |
アクセストークンの有効期限 |
scope |
String |
スコープ |
issuedAt |
String |
アクセストークンの発行日日付 |
サンプルレスポンス
| {
"accessToken": "9944b09199c62bcf9418ad846dd0e4bbdffgtyh",
"tokenType": "BearerToken",
"expiresIn": "86399" ,
"scope": "" ,
"issuedAt": "100000000"
}
|
サンプルコード
Shell
| curl -X POST \
-H "Content-Type: application/json" \
-d '{
"grantType": "client_credentials",
"clientId": "<Client ID>",
"clientSecret": "<Client Secret>"
}' \
https://api.customer.jp/v1/oauth/accesstokens
|
Python
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | import json
import requests
response = requests.post(
"https://api.customer.jp/v1/oauth/accesstokens",
headers={"Content-Type": "application/json"},
data=json.dumps({
"grantType": "client_credentials",
"clientId": "<CLIENT ID>",
"clientSecret": "<CLIENT SECRET>"
})
)
print(response.status_code)
print(response.json())
|