How to implement custom OpenID Relying Party in MV

2020-07-24 03:00发布

I like the new MVC OpenID/OAuth login feature, but I want to know how to add a new login button, for example I want my users to login using their StackExchange account or using their OpenID url the same as in stackoverflow http://puu.sh/13rm0

How to do that? Are there any samples showing this in steps?

1条回答
Explosion°爆炸
2楼-- · 2020-07-24 03:36

Unfortunately the API Microsoft exposes is limited to login providers that are hard-coded to a specific URL -- not one that can accept input from the user before logging the user in, which OpenID requires.

You can add support for specific OpenID providers such as StackExchange by creating a class that implements DotNetOpenAuth.AspNet.IAuthenticationClient and is hard-coded to use StackExchange. A great example of this is the source code for Microsoft's own provider for Yahoo!. Check it out, see how simple it is, then create your own that is simply hard-coded to https://openid.stackexchange.com/ instead of https://me.yahoo.com/ and you've got StackExchange login support.

查看更多
登录 后发表回答