与django-social-auth的Google登录错误

Kis*_*e K 2 django google-api django-socialauth oauth-2.0 google-oauth

我创建了一个django项目,使用django-social-auth登录谷歌.

我按照文档在Google开发者控制台中使用"OAuth 2.0"创建了一个应用程序并添加了API

Gmail API, Google+ API,  Google+ Domains API and Google+ Hangouts API
Run Code Online (Sandbox Code Playgroud)

在凭证中,我已将AUTHORIZED REDIRECT URIS设置为我的生产服务器URL"mysite.com".

我使用"CLIENT ID"和"CLIENT SECRET"配置了django设置.此设置在我的本地服务器上完美运行,用户已创建,并且电子邮件与用户关联.

但是当我搬到生产服务器时,我得到了错误

"400. That’s an error. OpenID auth request contains an unregistered domain: mysite.com". 
Run Code Online (Sandbox Code Playgroud)

有没有其他人面临类似的问题?

sre*_*nth 5

我也有类似的问题,我修复如下:

  1. 如果您的Google登录网址是/login/google/,请将其更改为/login/google-oauth2/
  2. 在您的Google应用设置中添加以下重定向URI

http://<your domain>/<social-auth-prefix-if-any>/complete/google-oauth2/ http://<your domain>/<social-auth-prefix-if-any>/associate/complete/google-oauth2/

希望这可以帮助.