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表。拿到昵称头像,显示到首页

 

posted @ 2019-08-08 20:18  一觉昏睡人  阅读(749)  评论(0编辑  收藏  举报