How to get my own Facebook user access token indefinitely?

隐身守侯 提交于 2019-12-14 03:37:53

问题


I want to pull my most recent images from facebook's api for my personal website. I cannot seem to find a way to only authenticate my user without the login dialog. Does anyone know if this is possible? I can generate my user access token inside the graph API Explorer, but it expires in 1 hour.


回答1:


How to get my own Facebook user access token indefinitely

You cannot!

But you can extend this token that will be valid for 60 days - called the long-lived token. So, if a user visits your application at least once in 60 days you can have the access to user's data indefinitely.

Simple call to get the long-lived user access token-

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

Refreshing this token- The user have to go through the login process again (calling login API) to get the short-lived token and then perform the same exchange for a fresh long lived token with 60 days expiry.

You can also debug your token anytime with-

GET /debug_token?
    input_token={input-token}&    
    access_token={access-token}  // a valid user access token or app access token


来源:https://stackoverflow.com/questions/29059057/how-to-get-my-own-facebook-user-access-token-indefinitely

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!