What is the correct way to refresh Facebook OAuth2 access token after it expires?

后端 未结 6 2029
北恋
北恋 2020-12-07 10:55

As I understand it, this is the basic process for new Facebook iframe canvas apps using the OAuth2 API in a nutshell:

  1. Redirect to (or have user click link to)
6条回答
  •  無奈伤痛
    2020-12-07 11:46

    //you just need more step because the access token you are getting will expire in 1 hour
        //you can overcome this in step 5
    
        1-Redirect to (or have user click link to) app's authorization URL
    2-User authorizes and is redirected to your callback URL
    3-Callback uses "code" parameter to get a access token
    4-Access token is used with Graph API to pull or push information
        5-exchange short-lived access token you just got with 60 day access token
        https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=fb_exchange_token&fb_exchange_token=EXISTING_ACCESS_TOKEN
        6-after 60 day the user must login again to your app and the steps from 1-5 will be repeated.
        --the real problem you will face is how to make the user visit your app page again
    

提交回复
热议问题