var facebookClient = new FacebookClient
{
ClientIdentifier = "appId",
ClientSecret = "appSecret"
};
IAuthorizationState authorization = facebookClient.ProcessUserAuthorization();
if (authorization == null)
{
// Kick off authorization request
facebookClient.RequestUserAuthorization();
}
else
{
var request =
WebRequest.Create("https://graph.facebook.com/me?access_token=" +
Uri.EscapeDataString(authorization.AccessToken));
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
var graph = FacebookGraph.Deserialize(responseStream);
lblFacebookUserName.Text = HttpUtility.HtmlEncode(graph.Name);
}
}
}
линиюКак войти в facebook с помощью DotNetOpenAuth
IAuthorizationState authorization = facebookClient.ProcessUserAuthorization();
всегда возвращают null
Обратите внимание, что в новой версии DotNetOpenAuth.ApplicationBlock, ClientSecret не существует. Теперь это должно быть следующим: FacebookClient fbClient = new FacebookClient { ClientIdentifier = "appId", ClientCredentialApplicator = ClientCredentialApplicator.PostParameter ("appSecret") }; –