Search Unity

Question Does Facebook refresh Facebook Access Token automatically?

Discussion in 'Scripting' started by SaariTech, Dec 10, 2022.

  1. SaariTech

    SaariTech

    Joined:
    Jan 6, 2014
    Posts:
    22
    Facebook have Access Token for security reasons, I can refresh it manually but what worries me is that if a user login Facebook after a long time or getting a new device after the expiration date, does Facebook api renew Access Token automatically or the Access Token is same as before after the expiration date? If Facebook renew the Access Token automatically then we will get problems with accessing game server.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    You should include links to all of the various Facebook documentation that you checked already.

    Otherwise we might have to waste our time checking the same links you already checked, and that would be silly.
     
  3. SaariTech

    SaariTech

    Joined:
    Jan 6, 2014
    Posts:
    22
  4. Nad_B

    Nad_B

    Joined:
    Aug 1, 2021
    Posts:
    730
    Just refresh it each time the app starts (or before issuing your first FB API call) and don't worry about it, it'll take only few milliseconds to do so, so it's not noticeable at all.
     
  5. SaariTech

    SaariTech

    Joined:
    Jan 6, 2014
    Posts:
    22
    The point is I'm using both old and new access token to update the Access Token in game server to prevent malicious users. Facebook might have api for server too.. I might need that too.
     
  6. SaariTech

    SaariTech

    Joined:
    Jan 6, 2014
    Posts:
    22
    I solved it, I'm using
    Code (CSharp):
    1. AccessToken.CurrentAccessToken.TokenString
    and refresh the access token before sending to server, use request in node.js to https://graph.facebook.com/me?access_token={access_token} to check if the facebook id from client with access token is same. No fb api needed in server.