使用iOS 6的social.Framework(叽叽喳喳的OAuth)登录到一个ASP.NET MVC 4个网站 [英] Using iOS 6 social.Framework (twitter oauth) to login to an ASP.NET MVC 4 site
本文介绍了使用iOS 6的social.Framework(叽叽喳喳的OAuth)登录到一个ASP.NET MVC 4个网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有使用ASP.NET MVC 4内置一个网站其内置的OAuth登录整合到Twitter。
我也有一个使用social.Framework和Twitter的反向AUTH获取OAuth令牌+秘密存储在设备上的Twitter帐户的iOS原生应用程序。
如何使用iOS的凭据托管在我的ASP.NET MVC 4网站的网页和Web服务?
解决方案
- 在AccountController.cs,克隆ExternalLoginCallback操作方法有不同的URL,并添加oath_token和oauth_token_secret方法参数。
- 取出VerifyAuthentication通话和检查。
- 查看是否User.Identity.IsAuthenticated,如果是这样,WebSecurity.Logout()和返回重定向(Request.Url.ToString())。
- 呼叫Twitter的/account/verify_credentials.json(签字)来验证OAuth令牌,并获得SCREEN_NAME。请确保您使用RFC3896编码(如%2B未%2B),否则将无法正常工作。
- 用推特替换result.Provider。
- 与SCREEN_NAME替换result.ProviderUserId。
I have a site built using ASP.NET MVC 4 with its built-in login OAuth integration to Twitter.
I also have an iOS native app that uses social.Framework and twitter's reverse auth to get an oauth token+secret for a twitter account stored on the device.
How can use the iOS credentials to pages and web services hosted on my ASP.NET MVC 4 site?
解决方案
- In AccountController.cs, clone ExternalLoginCallback action method with a different url and add oath_token and oauth_token_secret method parameters.
- Remove the VerifyAuthentication call and check.
- Check to see if User.Identity.IsAuthenticated, if so, WebSecurity.Logout() and return Redirect(Request.Url.ToString()).
- Call Twitter's /account/verify_credentials.json (signed) to validate the oauth token and get the screen_name. Make sure you use RFC3896 encoding (eg. %2B not %2b) or it won't work.
- Replace result.Provider with "twitter".
- Replace result.ProviderUserId with screen_name.
这篇关于使用iOS 6的social.Framework(叽叽喳喳的OAuth)登录到一个ASP.NET MVC 4个网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文