Refresh token and Access token in facebook API

后端 未结 2 1048
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-02 16:09

When we do oauth2 on google api, we get an access token and a refresh token. Suppose I\'m writing a service and I want to periodically poll for changes I can just use refre

相关标签:
2条回答
  • 2021-01-02 16:37

    For offline access, you need to exchange your short-lived access token for a new access token, before it expires. Facebook has a single type of access token (no refresh tokens). A about-to-expire access token should fetch you a new access token.

    To manually extend the tokens using a Graph API endpoint ::

    GET /oauth/access_token?  
        grant_type=fb_exchange_token&           
        client_id={app-id}&
        client_secret={app-secret}&
        fb_exchange_token={short-lived-token}
    

    Quoting FB's documentation from here ::

    Apps are unable to exchange an expired short-lived token for a long-lived token. The flow above only works with short-lived tokens that are still valid. Once they expire, your app must send the user through the login flow again.

    Do read the Expiration and Extending Tokens portion of the documentation link that I have mentioned for further clarification.

    0 讨论(0)
  • 2021-01-02 16:37

    You can check the validity of your token from here , according to my token it expires never

    0 讨论(0)
提交回复
热议问题