Open stacklens opened 4 years ago
旧评论区读者问题集中帖:
Q:git头像是怎么获取的?
A:user.socialaccount_set.all.0.get_avatar_url
用django-allauth第三方登录会返回很多数据,比如用户头像、性别、年龄等,这些在后台里都能查的到的。
我这github失败... 换baidu的也失败..
就第一次能正确转到等三方授权页面, 然后就显示KeyError at /accounts/github/login/callback/
错误信息:
求指点 T . T
我这github失败... 换baidu的也失败.. 就第一次能正确转到等三方授权页面, 然后就显示
KeyError at /accounts/github/login/callback/
错误信息:
求指点 T . T
把缓存清了呢?
我这github失败... 换baidu的也失败.. 就第一次能正确转到等三方授权页面, 然后就显示
KeyError at /accounts/github/login/callback/
错误信息:
求指点 T . T
把缓存清了呢?
我这github失败... 换baidu的也失败.. 就第一次能正确转到等三方授权页面, 然后就显示
KeyError at /accounts/github/login/callback/
错误信息: 求指点 T . T把缓存清了呢?
换了台机器重新部署了一遍还是这样... 验证成功了, github也发来了邮件提示已经完成授权...
A third-party OAuth application (django第三方登录) with access to public information (read-only) was recently authorized to access your account. 然后就这个页面了.... 重新登录也一样, 也尝试了清除缓存... 是不是因为项目里面没有保存用户信息的部分呢? 所以对callback没有相应的处理..?
''' def extract_uid(self, data): return str(data['id']) # 提示是这里出现了错误, 导致 uid = self.extract_uid(response) 错误 def extract_common_fields(self, data): return dict(email=data.get('email'), username=data.get('login'), name=data.get('name'))
'''
好像是它某个函数需要的data字典
里面没有'key值'为'id', 所以报错....
昨晚上换了百度的oauth接口也是这样=- =
额, 我昨天clone了你的django-blog-tutorial项目, 然后也是一样显示这个错误.... 可能感觉我的安装包版本出了问题
额, 我昨天clone了你的django-blog-tutorial项目, 然后也是一样显示这个错误.... 可能感觉我的安装包版本出了问题
有这个可能。比如 Django 版本和库的版本对应不上,或者这个库已经没维护了。毕竟教程都是几年前写的
求大佬帮忙看看,这字段该怎么改啊
大佬,这个id问题我弄了一天都没整出来,求助大佬!
KeyError at /accounts/github/login/callback/
'id'
Request Method: GET
Request URL: http://127.0.0.1:8000/accounts/github/login/callback/?code=39d44993c0b6a733e9ba&state=DFUD7398HPdK
Django Version: 2.2.13
Exception Type: KeyError
Exception Value:
'id'
Exception Location: D:\myMajor\workstation\django_blog\env\lib\site-packages\allauth\socialaccount\providers\github\provider.py in extract_uid, line 38
Python Executable: D:\myMajor\workstation\django_blog\env\Scripts\python.exe
Python Version: 3.7.0
Python Path:
['D:\\myMajor\\workstation\\django_blog',
'D:\\myMajor\\workstation\\django_blog\\env\\Scripts\\python37.zip',
'D:\\softwares\\Anaconda3\\DLLs',
'D:\\softwares\\Anaconda3\\lib',
'D:\\softwares\\Anaconda3',
'D:\\myMajor\\workstation\\django_blog\\env',
'D:\\myMajor\\workstation\\django_blog\\env\\lib\\site-packages']
Server time: Sat, 24 Apr 2021 22:46:56 +0800
求大佬帮忙看看,这字段该怎么改啊
别慌, 两个月了我也还是没弄出来哈哈哈哈哈哈
现在改用vue+DRF前后分离写项目了, 最近刚忙完, 回来重新研究下第三方登录.
大兄弟你这找出问题来了么~
我也卡在这里。。。 难搞哦
时隔半年, 重新拿起这个项目. 解决方案就是自己手撸Oauth2的api.
内网github老是来大姨妈, 各种问题... 最后接入了gitee和qq第三方登录. 推荐先用gitee试水, 审核简单, 做demo很合适. QQ断断续续申请了几个月还没过审核...
ERROR: Could not install packages due to an OSError: [WinError 5] 拒绝访问。: 'C:\Users\xxxxxxx\AppData\Local\Temp\pip-install -t050pipw\django-allauth_7bbcc6a7fa4d4a4f8ba0154872f83a34\allauth/socialaccount/providers/baidu' Check the permissions.
不管我怎么搞,它就是报这个错
由于是py3.10,换到py3.9试试,django3.2,但错误基本上还是一样的: build\lib\allauth\socialaccount\providers\authentiq creating build\lib\allauth\socialaccount\providers\azure copying allauth\socialaccount\providers\azure\models.py -> build\lib\allauth\socialaccount\providers\azure copying allauth\socialaccount\providers\azure\provider.py -> build\lib\allauth\socialaccount\providers\azure copying allauth\socialaccount\providers\azure\tests.py -> build\lib\allauth\socialaccount\providers\azure copying allauth\socialaccount\providers\azure\urls.py -> build\lib\allauth\socialaccount\providers\azure copying allauth\socialaccount\providers\azure\views.py -> build\lib\allauth\socialaccount\providers\azure copying allauth\socialaccount\providers\azure__init__.py -> build\lib\allauth\socialaccount\providers\azure creating build\lib\allauth\socialaccount\providers\baidu error: could not create 'build\lib\allauth\socialaccount\providers\baidu': 拒绝访问。 [end of output]
note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure
Encountered error while trying to install package.
真的想不出怎么搞定了, 或者有没有其它allauth的库?
error info: You are about to sign in using a third party account from GitHub.
error info: An error occurred while attempting to login via your social network account.
Environment:
Request Method: POST Request URL: http://127.0.0.1:8000/accounts/github/login/?process=login
Django Version: 2.2 Python Version: 3.7.0 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.sites', 'django.contrib.staticfiles', 'password_reset', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.github', 'allauth.socialaccount.providers.weibo', 'article', 'userprofile', 'comment', 'taggit', 'ckeditor', 'mptt', 'notifications', 'notice'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "E:\django_project\env\lib\site-packages\django\core\handlers\exception.py" in inner
File "E:\django_project\env\lib\site-packages\django\core\handlers\base.py" in _get_response
File "E:\django_project\env\lib\site-packages\django\core\handlers\base.py" in _get_response
File "E:\django_project\env\lib\site-packages\allauth\socialaccount\providers\oauth2\views.py" in view
File "E:\django_project\env\lib\site-packages\allauth\socialaccount\providers\base\mixins.py" in dispatch
File "E:\django_project\env\lib\site-packages\allauth\socialaccount\providers\oauth2\views.py" in login
File "E:\django_project\env\lib\site-packages\allauth\socialaccount\providers\base\provider.py" in get_app
File "E:\django_project\env\lib\site-packages\allauth\socialaccount\adapter.py" in get_adapter
File "E:\django_project\env\lib\site-packages\allauth\utils.py" in import_attribute
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37\Lib\importlib__init__.py" in import_module
File "
File "
File "
File "
File "
File "
File "
Exception Type: ModuleNotFoundError at /accounts/github/login/ Exception Value: No module named 'main'
在django2.2的环境需要指定安装对应版本: pip install django-allauth==0.54.0
https://www.dusaiphoto.com/article/66/