轻易云
注册体验
POSThttps://dopen.weimob.com/fuwu/b/oauth2/token?grant_type=client_credentialsclient_id + client_secret(client_credentials)

自有型应用获取 access_token(客户端模式)

微盟云自有型应用鉴权接口:OAuth2 客户端模式,凭 client_id + client_secret(+ shop_id/shop_type)换取 access_token(有效期 2 小时),之后凭 token 调用微盟云 OpenAPI。

## 接口说明 微盟云产品应用分自有型(自研商家使用)与工具型(服务商多商家授权)。自有型应用采用 OAuth2 客户端模式(client_credentials)换取 access_token:POST 本接口,query 携带 grant_type=client_credentials、client_id、client_secret,以及店铺参数 shop_id、shop_type。token 有效期 2 小时,调用方必须缓存复用,频繁刷 token 会被限流。 ### 调用步骤 1. 在微盟云控制台创建产品应用(自有型),在【概览 → 开发配置】获取 client_id、client_secret,并将测试店铺绑定到应用。 2. 调用本接口换取 access_token(响应中 access_token 字段)。 3. 在控制台【能力中心】申请所需 API 能力(如订单、商品),审核通过后接口才可用。 4. 业务调用路径格式:https://dopen.weimob.com/api/1_0/{接口路径}?accesstoken=xxx。 ### 响应 成功:{"code":{"errcode":"0","errmsg":"success"},"data":{"access_token":"...","expire_in":7200,...}}。errcode 非 "0" 时按 errmsg 排查。 ### 注意事项 - 微盟云接口的错误包在 code.errcode 里,业务数据在 data 里,解析时不要按 HTTP 状态码判断业务成败。 - token 是店铺(shop_id)维度的,多店铺商家要为每个店铺分别维护 token。

代码示例

curl
curl -X POST "https://dopen.weimob.com/fuwu/b/oauth2/token?grant_type=client_credentials&client_id=xxxx&client_secret=yyyy&shop_id=12345&shop_type=1"

错误码

错误码消息含义
0success成功
client_invalid客户端凭据无效client_id/client_secret 错误或应用未绑定店铺
token_expiredtoken 过期2 小时有效期到,重新获取