Today, I tried to add Facebook OAuth login feature into my ASP.NET MVC 4 application. Here is the step to add that feature:
1. Open AuthConfig.cs that you can find in App_Start folder in your project.
2. Un-comment the Facebook client register code and insert yout application id and application secret as bellow:
OAuthWebSecurity.RegisterFacebookClient(
appId: "32499828342XXXX",
appSecret: "3242kjsfudfsoirewXXXX");
3. And then run your application and go to http://yourmachine/Account/Login, you will find a button for login using your Facebook account. Try to press that button, if it is successful then you have configure your Facebook app correctly.
Common Error:
When you press Facebook button It will redirect and give this kind of error message:
-----------------------------------------------------------------
Given URL is not allowed by the Application configuration.: One or more of the given URLs is not allowed by the App's settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains
-----------------------------------------------------------------
To resolve this problem you need to open you developer.facebook.com account and open your application go to Settings > Advanced, search for Valid OAuth redirect URIs field and insert http://yourmachine/ExternalLoginCallback, since you are using ASP.NET MVC4, or change to other callback url that you need.
That's it for today.. :D
Thank you.
Life of a programmer full of learning, errors, achievement, and passion. Every code we type is meaningful in our life. Proud to be a programmer.
Friday, April 11, 2014
Subscribe to:
Posts (Atom)
Finally, C# 9 record, the equivalent of Scala's case class
While C# is a wonderful programming language, there is something that I would like to see to make our life programmer easier. If you are fam...
-
I'm using git as my version control for my unity projects. In my second project, I have problem with vast amount of file changes generat...
-
While C# is a wonderful programming language, there is something that I would like to see to make our life programmer easier. If you are fam...
-
If you are tired of being asked for a password when accessing your remote droplet servers in Digitalocean, you might consider adding an rsa ...