获取Access Token

接口描述

本接口用于获取OAuth2 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对应企业ID和企业密钥
Content-Type String 固定值 application/x-www-form-urlencoded

请求参数说明

参数名 类型 必填 说明
grant_type String 固定值 client_credentials

接口返回示例

成功

{
    "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
tokey_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 Status
error String 错误类型
message String 错误消息