How to implement custom OpenID Relying Party in MVC 4

跟風遠走 提交于 2020-01-01 14:44:10

问题


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:


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.



来源:https://stackoverflow.com/questions/12338224/how-to-implement-custom-openid-relying-party-in-mvc-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!