Me and some guys here are working on an start up. We are currently using Google OpenID API to manage registration and login to our app, but we want to migrate to a easier user r
You can check the Identity Provider with a google api https://dns.google.com/resolve?name=example.com&type=MX
public static class IdentityProviderChecker
{
public static async Task GetProviderName(string email)
{
var domainName = email.Split('@').Last();
using var client = new HttpClient();
var result = await client.GetAsyncResult($"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!;
}