Access Tokenを取得

OpenAPI説明

当該OpenAPIはOAuth2 AccessTokenを取得するために利用します。取得したAccessTokenは後続のOpenAPI呼び出しに必要な情報です。

リクエストURI

/oauth/token

リクエスト形式

POST

リクエストパラメータ例

curl https://[env].spendia.jp/oauth/token \
    -X POST \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -u [client_id]:[client_secret] \
    -d "grant_type=client_credentials"

ヘッダーパラメータ

ヘッダーパラメータ名 タイプ 必須 説明
Authorization String Basic base64.encode(${client_id}:${client_secret})
1. ${client_id}:${client_secret}に対しBase64エンコード変換
2. client_idとclient_secretはそれぞれSpendia画面から参照可能な「企業ID」と「企業キー」に対応する
Content-Type String 固定値 application/x-www-form-urlencoded

リクエストパラメータ説明

パラメータ名 タイプ 必須 説明
grant_type String 固定値 client_credentials

OpenAPIリターン例

成功例

{
    "access_token": "a12e078e-0fa1-4d78-be25-e09ca5af0340",
    "token_type": "bearer",
    "expires_in": 86399,
    "scope": "read write",
    "companyOID": "d52b2787-e1c3-49fb-9a12-7897946464",
    "tenantId": "1070599070258343938"
}

項目説明

項目名 タイプ 説明
access_token UUID OpenAPI呼び出しに必要なAccessToken
token_type String 固定値。bearer
expires_in int 有効期間。2時間(7200S)
scope String OAuth Scope
companyOID String 会社OID
tenantId String テナントID

失敗例

{
    "timestamp": "2020-02-19T14:03:03Z",
    "status": 401,
    "error": "Unauthorized",
    "message": "Bad credentials"
}
項目名 タイプ 説明
timestamp Date タイムスタンプ
status int Http ステータス
error String エラータイプ
message String エラーメッセージ