我正在使用https://github.com/python-social-auth/social-app-django
使我的django应用程序添加新的oauth变得容易。
我已将其添加到我的设置文件中并填写了密钥。
urls.py
urlpatterns = [
path('', include('home.urls')),
path('admin/', admin.site.urls),
path('auth/', include('social_django.urls', namespace='social')),
]
settings.py
SOCIAL_AUTH_COINBASE_KEY = os.environ.get('COINBASE_ID')
SOCIAL_AUTH_COINBASE_SECRET = os.environ.get('COINBASE_SECRET')
AUTHENTICATION_BACKENDS = (
'social_core.backends.open_id.OpenIdAuth', # for Google authentication
'social_core.backends.google.GoogleOpenId', # for Google authentication
'social_core.backends.google.GoogleOAuth2', # for Google authentication
'social_core.backends.coinbase.CoinbaseOAuth2', # for Coinbase authentication
'django.contrib.auth.backends.ModelBackend',
)
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'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',
'social_django.context_processors.backends', # <- Here
'social_django.context_processors.login_redirect', # <- Here
],
},
},
]
INSTALLED_APPS = [
'user.apps.UserConfig',
'django.contrib.humanize',
'social_django',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
然而,当我看到coinbase的oauth屏幕时,我按下,我被重定向到我的重定向uri,
然后它给了我一个错误
HTTPError at /auth/complete/coinbase/
403 Client Error: Forbidden for url: https://api.coinbase.com/v2/user
我一直试图解决这个问题几个小时,但我似乎无法找到任何关于此
的内容