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 7966593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:28:19+00:00 2026-06-04T06:28:19+00:00

My app uses Facebook Javascript SDK authorization on client side, and for authorized user

  • 0

My app uses Facebook Javascript SDK authorization on client side, and for authorized user app fetches access token from Facebook API, using facebook cookie with signed request and provided code, and store it into database.

Everything is working fine, but i’m wondering, when I should refresh stored access token? What if user have changes password, and have signed in/connected again.

As I understand, now she has new access token, and app should load it from Facebook. But how I can understand when I should check for a new token? Check on each request with facebook cookie doesn’t work, because it’s few request per second for each user (event if she didn’t change a password). Or maybe i’m doing something wrong?

I mean:

  • I’ve authorized user on client side
  • I’ve cookie with signed request
  • Signed request is pretty enough to authorize user on server side (validate user credentials)
  • I can get access token by calling Facebook API, anytime when user user makes request to my app (because I need a code from signed request). So, i’m doing it when I don’t have stored access token or existing access token has expired.
  • access token just stored in database, and can be used anytime, in different thread, maybe few minutes later (mean we don’t have user request and cookie with signed request)
  • What if stored access token not expired, but invalidated on facebook side? I need to fetch new access token, but cookie has gone at this moment.

Currently I see only one way: store code from signed request into databse, and when we have found that we have invalid access token, try to load it. But i’m note sure that it’s proper way, and not so much usable for most cases

  • 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-06-04T06:28:20+00:00Added an answer on June 4, 2026 at 6:28 am

    You have client token and server token, the client one is short lived (a few hours) and the server one is long lived (60 days).

    The token on the client side should not bother you too much since you can get a new one easily as it states in the “Handling Invalid and Expired Access Tokens” guide:

    Desktop Web and Mobile Web apps which implement authentication with the Javascript SDK

    Calling FB.getLoginStatus() or ensuring status: true is set when you
    call FB.init() means that the next time a user lands on your
    application and is signed into Facebook, the authResponse object you
    are passed as a result of those calls will contain a fresh, valid
    access token.

    In this case, its simply the act of the user using your application
    which implicitly generates a new access token.

    The token on the server side, which you persist in the db, can not be as easily reproduced, the user has to be sent to the auth dialog again:

    Desktop Web and Mobile Web apps which implement the server-side authentication flow

    To obtain a fresh access token in this case you must pass the user
    through the full server-side flow again: i.e. obtain a code and
    exchange it for a new access token.

    However, assuming the user has not de-authorized your application,
    when you redirect the user into the OAuth Dialog, the user will not be
    prompted to reauthorize your application, and will be immediately
    redirected to your redirect_uri. This means that the re-authentication
    process can appear transparent to the user.

    You can of course send a client token to the server and persist that, but it’s pretty pointless since it’s short lived.
    Another option is to use the new endpoint to extend a valid client token on the server side and then persisting that.

    As for “how to know when do get a new token”, on the server side when you are making api requests just check the response and see if an error returned and if so what it is (there’s a list in the first url I added).
    If the token has expired then just send the user to the auth dialog again (you can return some kind of code to the client side and do it from there) and then save the new token to the db.

    There’s no need to check cookies, those are used in the background but you should not have anything to do with them.


    Edit

    Don’t use the cookies, they should not concern you at any time.

    What you should do:

    On the server side you should follow the instructions in the Server-Side auth guide, get the “code” and exchange it with a token.
    That token will have 60 days.

    Use that token, which you store in your db, as needed (other threads, what not) and when you are getting an error back from facebook saying that the token has expires just navigate the user back to the auth dialog page.

    You can not use the “code” to get more than one token so that won’t help you.
    If the user session (and token) got invalidated (for various reasons) you will still get an error back from facebook when trying to make an api request, when that happens just send the user to the auth dialog again.

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

Sidebar

Related Questions

I was developing app which uses Facebook API authentication for user login. But sometimes
My facebook app uses the Facebook C# SDK to publish to a user's Facebook
I have an app in a page tab that uses the facebook javascript sdk.
My app uses an API from an external JAR file. This JAR file has
My app uses a per-user session to allow multiple sessions from the same user
I have an iPhone app which uses facebook. The user experience is not great
Our app uses the PHP- aswell as the JS-SDK of Facebook. We are able
I am building an iPhone app which uses Facebook iOS SDK and Three20. I
I'm creating an iPhone App that uses facebook connect to enable the user to
I'm getting all kinds of build errors with Facebook's SDK because my app uses

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.