问题
I have searched, read the FB developer docs.
MVC 4, I incorporated OpenId.
Now I want to include FB login as well, just as Stackoverflow and some other site have implemented it.
Do I create my own JS file with sample code from FB developer?
OR
Use a third party tools, which I am not aware of what to use. I did look at OAuthClient (DotNetOpenAuth-4.0.0.11165), it could not run, there was a server error and could not debug as the source file was missing.
回答1:
Facebook implements an older OAuth 2 spec than the latest DotNetOpenAuth beta does. To interop with Facebook, you should use the CTP of v3.5 of DotNetOpenAuth to avoid the 400 Bad Request error.
回答2:
In the latest release of DotNetOpenAuth (4.0.0.12084) Login with Facebook works fine.
In order to make Sample solution build: install Code Contracts: http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx
And to make example with Facebook login working you need to
- Create your own App on Facebook
- Specify you local website Url in the App settings (in "Select how your app integrates with Facebook" section)
- Update Web.config (OAuthClient project) file with your App ID and App Secret.
- in DotNetOpenAuth.ApplicationBlock.Facebook.FacebookGraph change type of Id property from int to long
- Run OAuthClient project. It should work.
More details here: Facebook/ Twitter with dotnetopenauth?
Also read Release notes regarding OAuth 2.0 (http://www.dotnetopenauth.net/oauth/dotnetopenauth-4-0-released/) As far as I understand it's not yet stable, but I'm sill studying this. So far it works fine for me.
回答3:
This post explain how to enable OAuth & OpenID authentication and integration in asp.net MVC 4 application.
http://www.dotnetexpertguide.com/2012/08/facebook-twitter-oauth-openid-login-with-aspnet-mvc-4-application.html
来源:https://stackoverflow.com/questions/9164740/how-to-log-in-with-facebook-using-dotnetopenauth