python-Web-django-qq扫码登陆

1.建路由

 

2.qq登录的a链接

3 在控制器的loginQq的方法:拼接url,跳转到这个url

 

https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=111111&redirect_uri=http://127.0.0.1:8000/blog/returns&state=123456

 

4 当用手机扫码成功后,网址自动跳回回调地址:

 

回:http://127.0.0.1:8000/blog/returns?state=12123&code=666666

 

可以拿到code666666验证码

 

拼接url

 

https://graph.qq.com/oauth2.0/token?grant_type=authorization_code&code=666666&client_id=111111&client_secret=xxxxxxed4cea42102e

 

通过openurl方法异步访问此url,返回值:拿到access_token:123456789密钥

 

拼接url

 

https://graph.qq.com/oauth2.0/me?access_token=123456789

 

通过openurl方法异步访问此url,返回值:拿到openid:110222132333336666666谁的信息

 

拼接url

 

:https://graph.qq.com/user/get_user_info?oauth_consumer_key=101436321&openid=110222132333336666666&access_token:123456789

 

通过openurl方法异步访问此url返回值:用户信息:昵称 ,头像,性别等

 

 

 

5.

 

根据openid查询member表中是否有这样的记录,没有添加,有的话,可以更新昵称等信息。跳转到首页

 

到首页:根据sessionopenid查询数据库member表。拿到昵称头像,显示到首页

 

转载于:https://www.cnblogs.com/person1-0-1/p/11323533.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值