问题
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?
回答1:
- 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.
来源:https://stackoverflow.com/questions/15095077/using-ios-6-social-framework-twitter-oauth-to-login-to-an-asp-net-mvc-4-site