Facebook with DotNetOpenAuth 4.1.0.12182

I am trying to create a user account for Facebook and Windows LiveId using DotNetOpenAuth 4.1.0.12182

However, boot examples use DotNetOpenAuth.ApplicationBlockand DotNetOpenAuth.ApplicationBlock.Facebookthat do not exist in the current assembly.

Instead, there is a namespace DotNetOpenAuth.AspNet.Clientsthat includes FacebookClientand WindowsLiveClient- however, I cannot find an example of how to use them.

Are there any examples or documentation?

+5
source share
2 answers

DNOA 4.1.0.12182,.Net 3.5 Facebook, , FacebookAuthClient, DotNetOpenAuth.OAuth2.WebServerClient. , , , cookie, OAuth. , , , DNOA , , . , Facebook.

FacebookAuthClient:

public class FacebookAuthClient : DotNetOpenAuth.OAuth2.WebServerClient
{
    private static readonly DotNetOpenAuth.OAuth2.AuthorizationServerDescription Description = new DotNetOpenAuth.OAuth2.AuthorizationServerDescription
    {
        TokenEndpoint = new Uri("https://graph.facebook.com/oauth/access_token"),
        AuthorzationEndpoint = new Uri("https://graph.facebook.com/oauth/authorize")    
    };

    public static readonly string [] ScopeNeeded = { "publish_stream" };

    public FacebookAuthClient()
       : base(Description)

    {
    }
}

Facebook.aspx.cs:

public partial class FacebookPage : System.Web.UI.Page
{
    private FacebookAuthClient _client = new FacebookAuthClient
    {
        ClientIdentifier = ConfigurationManager.AppSettings["FBClientId"], //The FB app Id
        ClientCredentialApplicator = DotNetOpenAuth.OAuth2.ClientCredentialApplicator.PostParameter(ConfigurationManager.AppSettings["FBClientSecret"]) // The FB app secret
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        DotNetOpenAuth.OAuth2.IAuthorizationState auth = _client.ProcessUserAuthorization();
        if (_auth == null)
        {
            // Kick off authorization request with the required scope info
            client.RequestUserAuthorization(FacebookAuthClient.ScopeNeeded);
        }
    }
}

, , , , .

Edit DotNetOpenAuth () NuGet .

Edit .PostParameter ClientCredentialApplicator.

+15

ctp 3.5 DNOA. 4+ OAuth 2, Facebook.

GitHub: https://github.com/AArnott/dotnetopenid

+1

All Articles