Я использую Django 1.8 на Python 3.6 с virtualenv, пытаюсь интегрировать логин Google с Django -allauth 0.23.0.Он отлично работает на python3 сервере (python3 manage.py runserver
), но дает ошибка ниже на рабочем сервере (Apache2 + wsgi)
Social Network Login Failure
An error occurred while attempting to login via your social network account.
Code: unknown, Error: Error retrieving access token: b'{\n "error": "invalid_scope",\n "error_description": "Some requested scopes were invalid. {valid\\u003d[https://www.googleapis.com/auth/userinfo.profile, https://www.googleapis.com/auth/userinfo.email, openid], invalid\\u003d[https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email, https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.profile]}",\n "error_uri": "http://code.google.com/apis/accounts/docs/OAuth2.html"\n}'
Установленные приложения приведены ниже
asgiref==3.2.3
certifi==2019.11.28
chardet==3.0.4
confusable-homoglyphs==3.2.0
defusedxml==0.6.0
Django==1.8
django-allauth==0.23.0
django-crispy-forms==1.8.1
django-registration==2.0
idna==2.9
mysqlclient==1.4.6
oauthlib==3.1.0
python3-openid==3.1.0
pytz==2019.3
requests==2.23.0
requests-oauthlib==1.3.0
sqlparse==0.3.0
urllib3==1.25.8
файл setting.py, включенный ниже
INSTALLED_APPS = (
#django apps
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
#third party apps
'crispy_forms',
'registration',
# 'custom_user',
#my app
# 'login',
'newsletter',
'accounts',
# #social login
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.facebook',
)
AUTHENTICATION_BACKENDS = [
'accounts.backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
# 'allauth.account.auth_backends.AuthenticationBackend',
]
# AUTH_USER_MODEL = 'auth.User'
# AUTH_USER_MODEL = 'custom_user.EmailUser'
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'tryDjango18.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, "templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'django.template.context_processors.request',
],
},
},
]
WSGI_APPLICATION = 'tryDjango18.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
#'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
#}
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '******',
'USER': '*****',
'PASSWORD': '****',
'HOST': 'localhost',
'PORT': '',
}
}
SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': [
'profile',
'email',
],
'AUTH_PARAMS': {
'access_type': 'online',
}
}
}
ACCOUNT_AUTHENTICATION_METHOD='username_email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = True
# Internationalization