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

alibaba.ailabs.tmallgenie.auth.getcode (获取token)

获取天猫精灵authCode

公共参数

请求参数

名称 类型 是否必须 示例值 更多限制 描述
auth_param TopAuthReqDto 可选 授权参数
  • └ response_type
  • String
  • 可选
  • qrcode
  • 二维码授权 只支持qrcode
  • └ client_id
  • String
  • 可选
  • YHNM
  • 天猫精灵分配的clientId
  • └ scope
  • String
  • 可选
  • basic
  • OAUTH2 scope 只支持basic
  • └ state
  • String
  • 可选
  • state
  • OAUTH2 state 随意填写
device_param TopDeviceReqDto 可选 设备参数
  • └ device_signature
  • String
  • 可选
  • YHNM
  • 设备签名
  • └ device_id
  • String
  • 可选
  • 123
  • 三方设备id

响应参数

名称 类型 示例值 描述
auth_code String {"code": "0f23d320062f430e9dfa1f98c5a054f5","qrcode": "https://h5.bot.tmall.com/download?xxx"} 授权码 json 串,包含授权码和二维码URL

请求示例

  • JAVA
  • .NET
  • PHP
  • CURL
  • Python
  • C/C++
  • NodeJS
TaobaoClient client = new DefaultTaobaoClient(url, appkey, secret);
AlibabaAilabsTmallgenieAuthGetcodeRequest req = new AlibabaAilabsTmallgenieAuthGetcodeRequest();
AlibabaAilabsTmallgenieAuthGetcodeRequest.TopAuthReqDto obj1 = new AlibabaAilabsTmallgenieAuthGetcodeRequest.TopAuthReqDto();
obj1.setResponseType("qrcode");
obj1.setClientId("YHNM");
obj1.setScope("basic");
obj1.setState("state");
req.setAuthParam(obj1);
AlibabaAilabsTmallgenieAuthGetcodeRequest.TopDeviceReqDto obj2 = new AlibabaAilabsTmallgenieAuthGetcodeRequest.TopDeviceReqDto();
obj2.setDeviceSignature("YHNM");
obj2.setDeviceId("123");
req.setDeviceParam(obj2);
AlibabaAilabsTmallgenieAuthGetcodeResponse rsp = client.execute(req);
System.out.println(rsp.getBody());

响应示例

  • XML示例
  • JSON示例
<alibaba_ailabs_tmallgenie_auth_getcode_response>
    <auth_code>{&quot;code&quot;: &quot;0f23d320062f430e9dfa1f98c5a054f5&quot;,&quot;qrcode&quot;: &quot;https://h5.bot.tmall.com/download?xxx&quot;}</auth_code>
</alibaba_ailabs_tmallgenie_auth_getcode_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>

错误码解释

错误码 错误描述 解决方案
500 服务内部错误 请先检查 message,如有疑问,联系开发人员解决
400 参数错误 请检查入参是否符合规范
401 未授权 请检查 clientId 和 appKey 是否正确
500004 签名错误 请检查 device_signature 参数是否正确

API工具

如何获得此API

FAQ

返回
顶部