文档中心 > API类目 > 人工智能实验室开放平台API

alibaba.ailabs.tmallgenie.auth.taobaoauth (天猫精灵淘宝登录授权绑定接口)

厂商获取用户淘宝授权之后,通过此接口获取天猫精灵授权,并绑定一台设备

公共参数

请求参数

名称 类型 是否必须 示例值 更多限制 描述
auth_param TopAuthReqDto 可选 授权信息
  • └ response_type
  • String
  • 可选
  • code
  • 目前只支持“code”
  • └ client_id
  • String
  • 可选
  • YHNM
  • 客户id,此id为天猫精灵的产品id,与淘宝登录的client_id不同
  • └ scope
  • String
  • 可选
  • basic
  • 目前只支持“basic”
  • └ state
  • String
  • 可选
  • TGV
  • state
device_param TopDeviceReqDto 可选 设备信息
  • └ device_signature
  • String
  • 可选
  • {xx}
  • 设备签名,用于校验设备有效性,对于部分client_id是必填的
  • └ device_id
  • String
  • 可选
  • TGBN
  • Device Serial Number,三方传入的设备唯一标识

响应参数

名称 类型 示例值 描述
register_result RegisterInfoVo {} 注册结果
  • └ user_open_id
  • String
  • YHNM
  • 用户开放ID,这个id标识您的天猫精灵用户
  • └ uuid
  • String
  • TVS
  • 天猫精灵设备UUID,用户需要保存这个id,后续的设备相关接口调用都会使用设备uuid
auth_result DeviceTokenVo {} 授权结果
  • └ access_expires_in
  • Number
  • 5000
  • token过期时间,相对时间,单位为秒
  • └ access_token
  • String
  • TGB
  • acces_token
  • └ refresh_expires_in
  • Number
  • 5000
  • token过期时间,相对时间,单位为秒
  • └ refresh_token
  • String
  • TGB
  • refresh_token

请求示例

  • JAVA
  • .NET
  • PHP
  • CURL
  • Python
  • C/C++
  • NodeJS
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
AlibabaAilabsTmallgenieAuthTaobaoauthRequest req = new AlibabaAilabsTmallgenieAuthTaobaoauthRequest();
AlibabaAilabsTmallgenieAuthTaobaoauthRequest.TopAuthReqDto obj1 = new AlibabaAilabsTmallgenieAuthTaobaoauthRequest.TopAuthReqDto();
obj1.setResponseType("code");
obj1.setClientId("YHNM");
obj1.setScope("basic");
obj1.setState("TGV");
req.setAuthParam(obj1);
AlibabaAilabsTmallgenieAuthTaobaoauthRequest.TopDeviceReqDto obj2 = new AlibabaAilabsTmallgenieAuthTaobaoauthRequest.TopDeviceReqDto();
obj2.setDeviceSignature("{xx}");
obj2.setDeviceId("TGBN");
req.setDeviceParam(obj2);
AlibabaAilabsTmallgenieAuthTaobaoauthResponse rsp = client.execute(req, sessionKey);
System.out.println(rsp.getBody());

响应示例

  • XML示例
  • JSON示例
<alibaba_ailabs_tmallgenie_auth_taobaoauth_response>
    <register_result>
        <user_open_id>YHNM</user_open_id>
        <uuid>TVS</uuid>
    </register_result>
    <auth_result>
        <access_expires_in>5000</access_expires_in>
        <access_token>TGB</access_token>
        <refresh_expires_in>5000</refresh_expires_in>
        <refresh_token>TGB</refresh_token>
    </auth_result>
</alibaba_ailabs_tmallgenie_auth_taobaoauth_response>

异常示例

  • XML示例
  • JSON示例
<error_response>
    <code>50</code>
    <msg>Remote service error</msg>
    <sub_code>isv.invalid-parameter</sub_code>
    <sub_msg>非法参数</sub_msg>
</error_response>

错误码解释

错误码 错误描述 解决方案

API工具

如何获得此API

FAQ

返回
顶部