title: Facebook OAuthException - This authorization code has expired. [code=100]
body: <p>I have setup the Facebook API SDK for ColdFusion - <a href="https://github.com/affinitiz/facebook-cf-sdk" rel="nofollow">https://github.com/affinitiz/facebook-cf-sdk</a></p>
  
  <p>I've setup a login process which works successfully but after 10 minutes or so when I return and refresh the page, it shows the following error:</p>
  
  <p>This authorization code has expired. [code=100]</p>
  
  <p>Is there something I am missing with the FB login? Am I meant to be checking against something manually in order to persist the session?</p>
  
  <p>Cheers</p>
  
  <p>Shaun</p>
  
  <pre><code>&lt;cfscript&gt;
     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);
         }
     }
  </code></pre>
  
  <p></p>