2014-10-04 37 views

回答

2

你只有靠這裏是讓最終用戶斷開他們的應用程序,然後重新連接它。

+0

謝謝,顯然你是對的。我認爲必須有某種方式來以編程方式測試重新連接過程,而不必使用實時令牌。 – Mike 2014-10-06 14:29:44

+0

您可以使用他們的OAuth操場自行測試,以生成已在30天到期範圍內的令牌。存儲這些令牌,然後調用您的重新連接代碼以確保它可以正常工作。 – 2014-10-06 15:03:02

+0

謝謝,我會給你一個鏡頭。 – Mike 2014-10-07 15:31:22

2

看一看:https://developers.facebook.com/docs/facebook-login/access-tokens

另外, 來自https://developers.facebook.com/blog/post/2011/05/13/how-to--handle-expired-access-tokens/

  • 令牌到期之後過期時間(2小時是默認值)。
  • 用戶更改她的密碼,使訪問令牌無效。
  • 用戶取消您的應用程序授權。
  • 用戶從Facebook註銷。

    令牌過期失效時間

這種情況指的是用戶已授權在過去您的應用程序的使用情況,但你發出的訪問令牌expired.When您嘗試使代表她的圖形API調用,你會得到一個HTTP 400在身體出現以下錯誤:

{ 
     error: { 
     type: "OAuthException", 
     message: "Session has expired at unix time 
      SOME_TIME. The current unix time is SOME_TIME.」 
     }, 
    } 

場景2:用戶更改自己的密碼

This scenario refers to use case where a user has authorized your app in the past and then she changes the password associated with her Facebook account. In this scenario, when you try to make Graph API call on her behalf you will get an HTTP 400 with the following error in the body: 

{ 
    error: { 
    type: "OAuthException", 
    message: "The session has been invalidated because 
     the user has changed the password.", 
    }, 
} 

Please note that you will receive this message even if your app was granted the offline_access permission if the user changed their password. 

方案3:用戶取消授權您的應用程序

This scenario refers to a use case where a user has authorized your app in the past, but then she de-authorizes your app by going to the App Dashboard. In this scenario when you try to make a Graph API call on her behalf you will get a HTTP 400 with the following error in the body: 

{ 
    error: { 
    type: "OAuthException", 
    message: "Error validating access token: USER_ID 
     has not authorized application APP_ID", 
    }, 
} 

Please note that even if the user had authorized your app with the offline_access permission access tokens will become invalid if the user de-authorizes your app. 

方案4:用戶登出Facebook上的

這種情況指的是用戶有一個用例授權您的應用程序在過去,然後她退出Facebook。如果用戶授權您的應用程序具有offline_access權限,那麼Graph API調用將按預期工作。如果用戶沒有授予此權限,並嘗試將代表用戶的圖形API調用,你會得到一個HTTP 400在身體出現以下錯誤:

{ 
    "error": { 
    "type":"OAuthException","message":"Error validating 
     access token: The session is invalid because the 
     user logged out." 
    } 
} 
+0

此問題應該是Intuit合作伙伴平臺問題組(QuickBooks)的一部分。對不起,如果不明確。 – Mike 2014-10-04 20:44:00

+0

我的不好,我誤讀了標籤。 :) – Petro 2014-10-07 21:19:42