# 接口调用凭证

该授权方式使用 OAuth2 的 client credentials 模式,获取小程序全局唯一后台接口调用凭据。

说明:access_token48小时内有效,未超出有效截止时间,开发者重新调用获取新的access_token,则新老token同时有效。避免token过期,开发者可根据业务实际情况,注意间隔请求时间,不要超出48小时。

# 请求地址

名称内容
HTTP URLhttps://open.kuaishou.com/oauth2/access_token
HTTP MethodPOST
content-typex-www-form-urlencoded 

# 参数

属性类型必填说明
app_idstring小程序的 app_id
app_secretstring小程序的密钥
grant_typestring固定值“client_credentials”

# 请求示例

curl --location --request GET 'https://open.kuaishou.com/oauth2/access_token?app_secret=9VfzaT-7Jf1bBHv-veFZfg&grant_type=client_credentials&app_id=ks707065143182458884' 

# 返回值

{
    "result": 1,
    "access_token": "xxxxxxx", 
    "expires_in": 23435,    
    "token_type" : "bearer"
}

说明

字段说明示例
access_token接入token,几乎所有OpenAPI接口都需要传入access_token才能通过ChFvYXV0aC5hY2Nlc3NUb2tlbhJQREzuPCu6S9HTR4etH5jep8ngfgBWotTzzo4oKass9so12s88aVS_VVhWLcygp4E--9IObpG92ItAj8WWZrAv6sGTYHLbT4knftXhotTAQDoaEshvFCVjVKMU-Fs4wE7NnP3X7iIgJ_B3Nxf6sEc0_L4uyqImsxUmEmhvM374mMNJYJwBb4IoDzAB
expires_intoken过期时间,单位:秒3600000
token_typetoken类型,固定为bearerbearer

# 错误码

当 result 不为 1 时,说明请求错误。错误码如下

错误码含义
100200100参数有误,需要检查参数是否为空或有误
100200101验证出错,需要检查app_id和app_secret
Copyright ©2024, All Rights Reserved