Allauth / Facebook无法发送/接受https。

3
我创建了一个应用并在DigitalOcean上部署,并使用Certbot启用了HTTPS。当我想要使用Facebook登录时,出现了错误。重定向URL不是HTTPS。以下是我的代码:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'social_django',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',

]

SOCIALACCOUNT_PROVIDERS = {
'facebook': {
    'METHOD': 'oauth2',
    'SCOPE': ['email', 'public_profile'],
    'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
    'INIT_PARAMS': {'cookie': True},
    'FIELDS': [
        'id',
        'email',
        'name',
        'first_name',
        'last_name',
        'verified',
        'locale',
        'timezone',
        'link',
        'gender',
        'updated_time',
    ],
    'EXCHANGE_TOKEN': True,
    'LOCALE_FUNC': 'path.to.callable',
    'VERIFIED_EMAIL': False,
    'VERSION': 'v2.12',
}

}

SOCIAL_AUTH_REDIRECT_IS_HTTPS = True

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
# 'social_core.backends.facebook.FacebookOAuth2',
'allauth.account.auth_backends.AuthenticationBackend',

)

登录按钮

{% load socialaccount %}
<a href="{% provider_login_url "facebook" method="oauth2" %}">Facebook OAuth2</a>

enter image description here

1个回答

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接