GitHub身份验证未使用主电子邮件。

huangapple go评论80阅读模式
英文:

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
在这里检查你的

GitHub身份验证未使用主电子邮件。

因此,你可以确定使用的电子邮件地址是公开的,而不是主要的。

如果你仍然想使用主要的电子邮件地址,你需要更改流程。首先,获取经过身份验证用户的电子邮件地址列表。你会得到类似于以下内容:

[
  {
    "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.

GitHub身份验证未使用主电子邮件。

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.

huangapple
  • 本文由 发表于 2023年2月6日 21:26:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/75361896.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定