1.进入https://open.shop.ele.me/openapi/register注册,登陆。
2.开发者中心-应用管理-新建应用,选择企业应用...保存。
3.开发者中心-应用管理-查看应用-沙箱环境,输入回调地址URL(http://ip:port/index.html),保存。
4.开发者中心-应用管理-应用授权,点击[应用授权链接],输入门店账号密码,登陆,一直到完成授权,成功后跳转至回调页面
http://ip:port/index.html?code=*****&state=*****。给到code(获取token所需参数)
5.base64_encode(key + ":" + secret)<开发者中心-应用管理-查看应用-沙箱环境中的key和secret>
,得到HTTP header中需要携带Authorization请求头(下一步要用)
6.安装chrome及其插件Advanced Rest Client(自行百度)
如下图所示,输入相关信息,获取token。
https://open-api-sandbox.shop.ele.me/token
Authorization: Basic OGlNb085T0pieTo0M2FhZjRhYTRhNTFmZDlhZTgyNzY3MmFlN2ViMGM5NTlkZGU0MmQ1(上一步获取的值)
grant_type=authorization_code&code=*****&redirect_uri=http://ip:port/index.html&client_id=8iMoO9OJby
grant_type:必须是authorization_code
code:第四步回调页面的code值
redirect_uri:回调url
client_id:沙箱环境的key
7.得到token后,就可以(用API调试台)调试了。