拼多多 | 您所在的位置:网站首页 › 拼多多网页登陆入口在哪里 › 拼多多 |
用户授权介绍 发布时间:2018-05-20 如果您的应用和拼多多开放平台对接时需要获取用户隐私数据(如商品-订单等),为保证用户数据的安全与隐私,您的应用需要取得用户的授权,即获取访问用户数据的授权令牌 access_token 。这种情况下,您的应用需要引导用户完成使用拼多多帐号“登录授权”的流程。该流程采用国际通用的OAuth2.0标准协议作为用户身份验证与授权协议,目前拼多多OAuth2.0服务支持采用两种方式获取Access_Token(授权令牌)。 1、请求入口地址1)获取授权码(code)商家授权正式环境:https://mms.pinduoduo.com/open.html移动端授权正式环境:https://mai.pinduoduo.com/h5-login.html多多客授权正式环境:https://jinbao.pinduoduo.com/open.html2)获取访问令牌(access_token)正式环境:https://open-api.pinduoduo.com/oauth/token 2、授权操作步骤实际进行授权操作时,以下按流程图逐步说明。 1)拼接授权url拼接用户授权需访问url ,示例及参数说明如下:商家授权:https://mms.pinduoduo.com/open.html?response_type=code&client_id=4b6**********************672e4c9a&redirect_uri=https://www.oauth.net/2/&state=1212移动端拼接授权URL:https://mai.pinduoduo.com/h5-login.html?response_type=code&client_id=4b6**********************672e4c9a&redirect_uri=https://www.baidu.com&&state=1212&view=h5多多客授权:https://jinbao.pinduoduo.com/open.html?client_id=4b6**********************672e4c9a&response_type=code&redirect_uri=https://hanshan.com ![]() 2)引导用户登录授权引导用户通过浏览器(移动端是手机浏览器)访问以上授权url,将弹出如下授权页面(只有商家主账号才能授权)。如果商家主账号已经登录,点“授权并登录”按钮授权即可,如果商家主账号未登录,点击“授权并登录”按钮即可进入登录页面,输入主账号用户名密码登录成功之后,跳回授权页面,点击“授权并登录”按钮,授权即可。注意事项:1)授权应用可直接重复授权2)授权应用后可在商家后台进行取消授权操作 ![]() ![]() 另外,移动端授权示例图如下: ![]() 3)获取code若用户点“授权并登录”按钮后,将授权码code 返回到了回调地址上,应用可以获取并使用该code去换取access_token;code有效期10分钟,10分钟后需要重新授权,多次使用code换取access_token是一样的,返回数据展示如下:https://redirect_url/?code=74afa4f59c4048d3aba7a152089e9db87797d6cc&state=1212 4)换取access_token利用linux 的curl 命令 获取access_token(授权令牌),注意,应用access_token有效期同服务市场订购时长(详细规则见下方“授权时长和授权数量说明”),过期后需要重新授权,access_token获取如下请求: curl-X POST -H"Content-Type: application/json" -d'{"client_id": "4b6**********************672e4c9a","code": "f80c147d96a144e88eb2e2006cccdffe3ba69215","grant_type": "authorization_code","client_secret": "fd82ce******************e2076b4751"}'"https://open-api.pinduoduo.com/oauth/token"注意事项: 请求方法必须为POST方法,请求Header必须设置Content-Type:application/json,请求报文内容必须为JSON格式报文包。 换取access_token请求参数说明 ![]() 示例:换取access_token返回值 { "scope": [ "pdd.logistics.companies.get", "pdd.logistics.online.send", "pdd.order.information.get", "pdd.order.number.list.get", "pdd.order.number.list.increment.get", "pdd.order.status.get", "pdd.refund.list.increment.get", "pdd.refund.status.check", "pdd.virtual.mobile.charge.notify" ], "access_token": "19eeaea897914e95907488d2f94b21ef26ef2687", "expires_in": 86400, "refresh_token": "75cd5b38e60d46c7a566521c792e0e7e9e341b4f", "owner_id": "213213" "owner_name": "pdd213213"} ![]() 刷新授权 操作方法类似获取access_token, refresh_token不会延长access_token的有效期,请求参数如下,refresh_token有效时间同授权时长,有效期内均可以请求刷新access_token,说明如下: ![]() refresh_token返回结果内容示例 { "scope": [ "pdd.logistics.companies.get", "pdd.logistics.online.send", "pdd.order.information.get", "pdd.order.number.list.get", "pdd.order.number.list.increment.get", "pdd.order.status.get", "pdd.refund.list.increment.get", "pdd.refund.status.check", "pdd.virtual.mobile.charge.notify" ], "access_token": "19eeaea897914e95907488d2f94b21ef26ef2687", "expires_in": 86400, "refresh_token": "75cd5b38e60d46c7a566521c792e0e7e9e341b4f", "owner_id": "1", "owner_name": "pdd213213"} 3.授权时长和授权数量说明 由于不同应用使用的场景、用户角色不同、信息类型,导致其敏感度不同,我们对不同的应用标签和状态定义了不一样的授权有效时长以及可授权数量 ![]() |
CopyRight 2018-2019 实验室设备网 版权所有 |