Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6929863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:22:21+00:00 2026-05-27T11:22:21+00:00

I’m having a problem where a user’s access tokens will expire, but the session

  • 0

I’m having a problem where a user’s access tokens will expire, but the session hasn’t leading to certain api calls throwing an exception.

I was hoping to be able to somehow call the access token’s expiration data directly, or at least some clean way of telling if the access token I’m using has already expired without having to first try an api call and catch the exception and read the error message.

Right now, in pseudo code I have

try {
    $permissions = getFBPerms();  # this seems to work fine even with expired tokens
    doFBApiCall(); # this will throw an exception withe expired tokens
}
catch (FacebookApiException $e) {
    var_dump($e); # this usually comes out to expired tokens
}

I want to be able to

if (checkFBTokenStatus())
    // do everything with no worries
else 
    gotoFBLoginUrl(); # re-log them in to get new access tokens

I also want a clean solution which I can adapt easily in case a user changed passwords, they authorized the app etc. I’m currently working off of this blog post but I dislike the way it works and it doesn’t really make sense. Furthermore, I’m hoping they’ve updated the mechanism since that blog post was put up. Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:22:22+00:00Added an answer on May 27, 2026 at 11:22 am

    What’s wrong with:

    try {
        $permissions = getFBPerms();  # this seems to work fine even with expired tokens
        doFBApiCall(); # this will throw an exception withe expired tokens
        // Do whatever you want...
    }
    catch (FacebookApiException $e) {
        gotoFBLoginUrl(); # re-log them in to get new access tokens
    }
    

    ?

    Of course, you can make a call to, for example, /me to check whether the token is valid, but that will imply executing one extra call before each API call, that doesn’t make much sense..

    Also, I wouldn’t rely on expiration date (tokens should least 3 hours from creation), since it might not be exact. Correct way is to catch the exception and then redirect the user to login page.

    Or, the brutal way, ask for tokens that doesn’t expire 🙂

    UPDATE: The deauthorize callback

    if you go in the “Advanced” pane of you app settings, you’ll find the “Deauthorize callback” field, in which you can insert an URL that is pinged when an user deauthorizes your app. This way, you have a certain way to tell whether an user removed your app.

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I need to clean up various Word 'smart' characters in user input, including but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.