英文:
Authentication using GitHub is not using the primary email
问题
最近在我的Django网站中集成了GitHub身份验证,并注意到Python Social Auth正在使用非主要电子邮件地址注册用户。
如何修改这种行为?
英文:
Recently integrated GitHub authentication in my Django website and noticed that Python Social Auth is registering the users using a non-primary email address.
How can that behaviour be modified?
答案1
得分: 1
根据设计,GitHub 的身份验证会使用GitHub在身份验证后返回的电子邮件地址。正如Alexander所指出,
> 返回的电子邮件地址是用户的公开可见电子邮件地址(如果用户在其个人资料中未指定公开电子邮件地址,则为null)。
根据下面的图像,你可以看到在我的情况下,它会返回 me@tiagoperes.eu
。
在这里检查你的。
因此,你可以确定使用的电子邮件地址是公开的,而不是主要的。
如果你仍然想使用主要的电子邮件地址,你需要更改流程。首先,获取经过身份验证用户的电子邮件地址列表。你会得到类似于以下内容:
[
{
"email": "octocat@github.com",
"verified": true,
"primary": true,
"visibility": "public"
}
]
然后,调整用户创建以使用主要的电子邮件地址。
英文:
By design, authentication with GitHub uses the email that GitHub returns after authentication. As noted by Alexander,
> The returned email is the user's publicly visible email address (or null if the user has not specified a public email address in their profile).
Based on the next image, you can see that in my case it'll return me@tiagoperes.eu
.
Check yours here.
So, you can settle that the email used is the public one and not the primary.
If you still want to use the primary email, you'll need change the pipeline. Start by getting the list email addresses for the authenticated user. You'll get something like this
[
{
"email": "octocat@github.com",
"verified": true,
"primary": true,
"visibility": "public"
}
]
Then, adjust the user creation to use the primary email instead.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论