gpt4 book ai didi

django - python-social-auth 与 django。无法在 VK.com 中获取用户电子邮件

转载 作者:行者123 更新时间:2023-12-02 05:59:54 25 4
gpt4 key购买 nike

settings.py 具有:

SOCIAL_AUTH_VK_OAUTH2_SCOPE = ['email'] 

但是这不起作用。同时我可以从 Facebook 收到电子邮件。

最佳答案

Django (1.9) 和 python-social-auth (0.2.13)

设置.py:

INSTALLED_APPS = [
...
'social.apps.django_app.default',
]

AUTHENTICATION_BACKENDS = (
'social.backends.vk.VKOAuth2',
'django.contrib.auth.backends.ModelBackend',
)

SOCIAL_AUTH_RAISE_EXCEPTIONS = True
RAISE_EXCEPTIONS = True


SOCIAL_AUTH_VK_OAUTH2_KEY = 'id_app'
SOCIAL_AUTH_VK_OAUTH2_SECRET = 'secret_key'
SOCIAL_AUTH_VK_OAUTH2_SCOPE = [
'notify',
'friends',
'email',
]

SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.social_auth.associate_by_email', # <--- enable this one
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details',
)

url.py:

urlpatterns = [
...
url(r'', include('social.apps.django_app.urls', namespace='social')),
url(r'', include('django.contrib.auth.urls', namespace='auth')),
]

auth.html:

<a href="{% url 'social:begin' 'vk-oauth2' %}?next={% url 'dashboard' %}">VK</a>

vk->应用程序->设置:

site address: http://127.0.0.1:8000
redirect uri: http://127.0.0.1:8000/complete/vk-oauth2/

关于django - python-social-auth 与 django。无法在 VK.com 中获取用户电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23524404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com