调试django-allauth社交网络登录失败 [英] Debugging django-allauth Social Network Login Failure
问题描述
使用django-allauth通过社交提供商进行OAuth登录时,有时会失败,并显示错误页面社交网络登录失败。没有包含更多信息的日志输出。此日志输出有一个功能请求( https://github.com/pennersr/django -allauth / issues / 1120 ),但已经开放了一年多。同时,如何获取更多信息来调试此错误?
When using django-allauth to do an OAuth login via a social provider, sometimes it fails with the error page "Social Network Login Failure". There is no log output containing more information. There is a feature request for this log output (https://github.com/pennersr/django-allauth/issues/1120) but it has been open for over a year. In the mean time, how do I get more information to debug this error?
推荐答案
更多信息传递给了用于呈现错误模板,但未在默认模板中使用。
More information is passed to the context used to render the error template but is not used in the default template.
您可以通过覆盖模板并在模板中包含以下内容来获取日志输出:
You can get log output by overriding the template and including in your template the following:
{{ auth_error }}
或:
Code: {{ auth_error.code }}, Error: {{ auth_error.exception }}
要覆盖模板,请在Django中添加一个文件夹模板DIRS。在Django 1.8+中,它类似于以下内容:
To override the template, add a folder to your Django template DIRS. In Django 1.8+, this looks like the following:
TEMPLATES = [
{
...
DIRS: [os.path.join(BASE_DIR, 'templates')]
}
]
然后在该文件夹中,创建目录 socialaccount
并将其放入名为 authentication_error.html $的文件中c $ c>
Then, in that folder, make directory socialaccount
and put in it a file called authentication_error.html
这篇关于调试django-allauth社交网络登录失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!