Facebook OAuthException - 此授权码已过期。 [代码= 100]

时间:2014-02-12 22:26:18

标签: facebook facebook-graph-api coldfusion cfml

我为ColdFusion设置了Facebook API SDK - https://github.com/affinitiz/facebook-cf-sdk

我已经设置了一个成功运行的登录过程但是在我返回并刷新页面大约10分钟后,它显示以下错误:

此授权码已过期。 [代码= 100]

FB登录时是否缺少某些内容?我是打算手动检查某些内容以便继续会话吗?

干杯

肖恩

<cfscript>
   import facebook.sdk.FacebookApp;
   import facebook.sdk.FacebookGraphAPI;

   // Replace this with your appId and secret
   APP_ID = "";
   SECRET_KEY = "";
   SCOPE = "publish_stream";

   if (APP_ID is "" or SECRET_KEY is "") {
       // App not configured
       facebookGraphAPI = new FacebookGraphAPI();
   } else {
       // Create facebookApp instance
       facebookApp = new FacebookApp(appId=APP_ID, secretKey=SECRET_KEY);

       // See if there is a user from a cookie or session
       userId = facebookApp.getUserId();
       if (userId) {
           try {
               userAccessToken = facebookApp.getUserAccessToken();
               facebookGraphAPI = new FacebookGraphAPI(accessToken=userAccessToken, appId=APP_ID);
               userObject = facebookGraphAPI.getObject(id=userId);
               userFriends = facebookGraphAPI.getConnections(id=userId, type='friends', limit=10);
               authenticated = true;
           } catch (any exception) {
               // Usually an invalid session (OAuthInvalidTokenException), for example if the user logged out from facebook.com
              // this is where the error occurs
              userId = 0;
              facebookGraphAPI = new FacebookGraphAPI();
           }
       } else {
           facebookGraphAPI = new FacebookGraphAPI();
       }

       // Login or logout url will be needed depending on current user state.
       if (userId) {
           logoutUrl = facebookApp.getLogoutUrl();
       } else {
           parameters = {scope=SCOPE};
           loginUrl = facebookApp.getLoginUrl(parameters);
       }
   }

1 个答案:

答案 0 :(得分:1)

显然,您没有将OAuth代码交换为访问令牌。请参阅此处的文档:Manually Build a Login Flow