Integrating facebook login and facebook c# SDK - NOT a facebook app
I downloaded the samples and the 5.0.3 beta of the SDK, and pretty quickly got a facebook app up and running inside facebook - great and super easy.
However, I want to use facebook only as an authorization-mechanism, and I cannot figure out how to do that from the examples and documentation (actually I was unable to find any documentation apart from a few examples here and there).
I found this piece of code without context here: Link
protected void Page_Load(object sender, EventArgs e)
{
if (!authorizer.IsAuthorized())
{
var authurl = a开发者_StackOverflowuthorizer.GetLoginUrl(new HttpRequestWrapper(Request));
CanvasRedirect(authurl.ToString());
}
else
{
LoggedIn(); // function to call when the user is logged in to init the page
}
}
This looks really interesting, but I cannot figure out what the authorizer is set up and used.
I am using MVC 3, but that should not really matter.
Is it possible to use the facebook c# sdk for this - and how?
I had the same question and I found my answer here maybe this will help with what you're after: http://amirrajan.net/Blog/asp-mvc-and-facebook-single-sign-on
DotNetOpenAuth CTP - Facebook bad request
The first answer there is good, with well-structured code with explanation, that I made work in a matter of minutes.
Seems that you've resolved your problem, but in case somebody stumbles upon this question - I've found this new library pretty easy to understand from code:
OAuth2Login on GitHub
Also there is pretty detailed article that explains the library:
OAuth2 Social Logins - Facebook, Google, Twitter, PayPal - ASP.NET MVC C# open source library
精彩评论