开发者

OpenID and Google hosted domains

开发者 https://www.devze.com 2022-12-28 13:17 出处:网络
I get an \"The remote name could not be resolved: \'mine.com\'\" When using this open ID identifier: https://www.google.com/accounts/o8/site-xrds?hd=mine.com

I get an "The remote name could not be resolved: 'mine.com'"

When using this open ID identifier: https://www.google.com/accounts/o8/site-xrds?hd=mine.com

And it's true, that the mine.com DNS record doesn't exist. But I'm wonderin开发者_运维技巧g why it goes to look there in the first place. All I want to be doing is to check if the user can login to our hosted domain. Is that really so hard?


I'm using DotNetOpenAuth and this is what I was missing...

relyingParty.DiscoveryServices.Insert(0, new DotNetOpenAuth.OpenId.HostMetaDiscoveryService { UseGoogleHostedHostMeta = true, });

By putting the HostMetaDiscoveryService first and allowing UseGoogleHostedHostMeta the request will work as expected.

Ends up something like this:

var relyingParty = new OpenIdRelyingParty();
relyingParty.DiscoveryServices.Insert(0, new DotNetOpenAuth.OpenId.HostMetaDiscoveryService { UseGoogleHostedHostMeta = true, });
var response = relyingParty.GetResponse();
if (response == null)
{
    var googleID = "https://www.google.com/accounts/o8/site-xrds?hd=my.domain";
    var request = relyingParty.CreateRequest(googleID);
    request.RedirectToProvider();
}
else
{
    switch (response.Status)
    {
        case AuthenticationStatus.Authenticated:
            break;

        default:
            break;
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号