Fer*_*her 7 openid api google-account single-sign-on
我和这里的一些人正在努力创业.我们目前正在使用Google OpenID API管理注册和登录我们的应用,但我们希望迁移到更简单的用户注册模式.为此,我们需要知道是否有一种方法可以检测到电子邮件(不是gmail)是否已经是Google帐户.有没有办法从Google Single Sign-on API获取此信息?
以前感谢您的帮助!:)
小智 12
如果您使用的是Mac,请打开终端并输入$ host {example.com}以确定他们的电子邮件是否由Google托管.
例如:
$ host yelp.com
yelp.com has address 104.16.57.23
yelp.com has address 104.16.56.23
yelp.com mail is handled by 1 ASPMX.L.GOOGLE.com.
yelp.com mail is handled by 10 ASPMX2.GOOGLEMAIL.com.
yelp.com mail is handled by 10 ASPMX5.GOOGLEMAIL.com.
yelp.com mail is handled by 10 ASPMX3.GOOGLEMAIL.com.
yelp.com mail is handled by 5 ALT2.ASPMX.L.GOOGLE.com.
yelp.com mail is handled by 10 ASPMX4.GOOGLEMAIL.com.
yelp.com mail is handled by 5 ALT1.ASPMX.L.GOOGLE.com.
Run Code Online (Sandbox Code Playgroud)
您可以使用 google api https://dns.google.com/resolve?name=example.com&type=MX检查身份提供商
public static class IdentityProviderChecker
{
public static async Task<string?> GetProviderName(string email)
{
var domainName = email.Split('@').Last();
using var client = new HttpClient();
var result = await client.GetAsyncResult<DnsResponse>($"https://dns.google.com/resolve?name={domainName}&type=MX");
return result.Answer.Any(x => x.Data.Contains("google.com", StringComparison.OrdinalIgnoreCase) || x.Data.Contains("googlemail.com", StringComparison.OrdinalIgnoreCase))
? "Google"
: result.Answer.Any(x => x.Data.Contains("outlook.com", StringComparison.OrdinalIgnoreCase))
? "Microsoft"
: null;
}
}
public class DnsResponse
{
public Answer[] Answer { get; set; } = null!;
}
public class Answer
{
public string Data { get; set; } = null!;
}
Run Code Online (Sandbox Code Playgroud)
你不能这样做。我认为未经用户同意谷歌不会告诉你这一点。
不过,您可以通过使用以下网址作为发现 URL 来查看该域是否为 Google Apps 域:https: //www.google.com/accounts/o8/site-xrds ?hd=mail.moztw.org
请注意,域管理员可能未正确安装域的 OpenID 支持。我的幻灯片详细讨论了这一点: http://www.slideshare.net/timdream/google-apps-account-as-openid
| 归档时间: |
|
| 查看次数: |
7678 次 |
| 最近记录: |