APP三方登录及绑定

2017-12-06  本文已影响147人  8813d76fee36

微信登录

官方文档链接
https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419317851&token=&lang=zh_CN

AppID、AppSecret保存在后台

App通过SDK发起授权请求,从微信获取临时票据code,将code传给后台,后台结合code、AppID、AppSecret换得openid和access_token等。

请求方式:GET https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code

获取access_token及openid等数据


请求参数说明
正确返回
错误返回

将获取的openid、access_token、refresh_token、unionid保存在后台数据库,其中access_token的过期时间由后台根据获取access_token时的当前系统时间加上过期时间得出过期时间戳存入数据库,如expireTime,用于判断access_token是否过期。

将openid返回给前端。

请求方式:GET
https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID

获取用户信息请求参数
正确返回结果
正确返回结果说明
错误返回结果

请求方式:GET
https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN

请求参数说明
正确返回结果及说明
错误返回结果

后台更新该用户access_token、refresh_token、token过期时间

上一篇下一篇

猜你喜欢

热点阅读