Python社交授权:谷歌登录错误(不允许用户)

2024-06-10 14:07:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在我的django项目中包含login with google服务,为此我使用social auth。在

在输入我的url后localhost:8000/secrets它将重定向到我的google帐户,并在我单击allow之后请求访问我的公共数据的权限,它将重定向到localhost:8000/login-errorurl并显示为 Authentication failed: User not allowed。在

任何帮助都将不胜感激!在


Tags: 项目djangoauthlocalhosturl权限withgoogle
1条回答
网友
1楼 · 发布于 2024-06-10 14:07:19

我终于解决了这个问题!!在

看看这个代码:

emails = setting('GOOGLE_WHITE_LISTED_EMAILS', [])
domains = setting('GOOGLE_WHITE_LISTED_DOMAINS', [])
if not emails and not domains:
    return True
if email in set(emails):
    return True # you're good
if email.split('@', 1)[1] in set(domains):
    return True
raise AuthFailed(backend, 'User not allowed')

删除设置中的GOOGLE_WHITE_LISTED_EMAILS和{}, 问题会解决的(对我而言)
~

相关问题 更多 >