1
我使用Facebook C#SDK v 6並在我的應用程序設置 上啓用了「刪除脫機訪問」,並且在登錄並獲取訪問令牌後,我試圖交換長壽命令牌(60天一個) 我無法得到它,因爲這兩個令牌在24小時內到期。無法獲得長期過期令牌
這裏是我的代碼
對於登錄到Facebook
private const string Scope = "publish_stream,manage_pages";
FacebookClient _fb = new FacebookClient();
var fbLoginUrl = _fb.GetLoginUrl(
new
{
client_id = AppId,
client_secret = Appsecret,
redirect_uri = RedirectUri,
response_type = "code",
scope = Scope,
state = state
});
爲了獲得短暫的訪問令牌
if (Request.QueryString["code"] != null)
code = Request.QueryString["code"];
var result = _fb.Post("oauth/access_token",
new
{
client_id = AppId,
client_secret = Appsecret,
redirect_uri = RedirectUri,
code = code,
scope = Scope,
response_type="token"
});
長期做下去住訪問令牌
var result1 = _fb.Post("oauth/access_token",
new
{
client_id = AppId,
client_secret = Appsecret,
grant_type = "fb_exchange_token",
fb_exchange_token= Session["fb_access_token"] as string
});
我認爲端點希望通過HTTP __GET__進行通話,而您正在使用POST ... – CBroe 2012-08-13 14:02:24
感謝您的回答。我嘗試HTTP GET仍然是相同的響應。如果我刪除了應用程序權限並重新添加,則在它提示權限對話框後第一次獲得應用程序權限(即長命令令牌)。但是,如果我再次運行相同的應用程序,它不會得到過期值。 – user1401299 2012-08-13 18:15:45
所以我想這可能是這個錯誤,https://developers.facebook.com/bugs/339375252810525你用調試工具檢查過你的標記,它們的實際壽命是什麼? https://developers.facebook.com/tools/debug – CBroe 2012-08-14 08:16:48