FacebookOAuthClient去哪儿了?

时间:2012-03-23 08:31:06

标签: oauth facebook-c#-sdk

我刚刚“升级”到c#SDK的6.1.0,发现FacebookAuthClient已被删除。我检查了github上的提交日志,那里没有太多信息。

有谁知道您应该如何使用最新版本的SDK进行身份验证?

1 个答案:

答案 0 :(得分:24)

它已被删除。

从v6开始,您现在可以使用普通FacebookClient.Get()方法。 http://csharpsdk.org/docs/faq.html

如何获取Facebook应用程序访问令牌?

var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new { 
    client_id     = "app_id", 
    client_secret = "app_secret", 
    grant_type    = "client_credentials" 
});

如何为访问令牌交换代码?

var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new {
    client_id     = "app_id",
    client_secret = "app_secret",
    redirect_uri  = "http://yoururl.com/callback",
    code          = "code"      
});

如何延长访问令牌的到期时间?

var fb = new FacebookClient();
dynamic result = fb.Get("oauth/access_token", new {
    client_id         = "app_id",
    client_secret     = "app_secret",
    grant_type        = "fb_exchange_token",
    fb_exchange_token = "EXISTING_ACCESS_TOKEN"
});