问题
I'm in the progress of reading all documentation of Facebook related to programming a Native Desktop application for Facebook. I explicitly state Native Desktop app. It will be using Client Side authentication WITHOUT the JAVA SDK.
As far as I have read, I know that access_tokens do expire. I've also read that you can re-authenticate. But........... Facebook has very limited documentation about how to do that with a desktop application running on Windows/Mac OSX or Linux using Client Side Authentication without the JAVA SDK.
My question is...... Is this possible anyway for such a Facebook desktop app or do I have to ask the user every time the access_token expires, to authorize my application again?
Important note: Facebook does not support the offline_access permission function/API (what a solution could have been) anymore.
回答1:
Found the solution.
Yes it is possible for a Native Desktop client to re-authenticate. The access_tokens (given by Facebook during app authentication by the user) forms the connection between the user, Facebook and my Desktop app. This access_token (a string of 111 tokens) is valid for 60 days. When it expires the user must authenticate again BUT does not have to mark all options again to specify the permissions my Native Desktop App may have.
It is then just a matter for the user to log onto facebook using the
https://www.facebook.com/dialog/oauth?client_id=YourAppClientIDGivenByFacebookDuringAppRegistration&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=PermissionsScope
again without any other action he or she have to do (just a login with the right URL with the right scope of permissions and thats it). The user of my Desktop app is then redirected to a URL that just shows the messages Success.
So you need a browser or you need to handle http get and post requests by code yourself.
来源:https://stackoverflow.com/questions/11408778/how-to-re-authenticate-native-desktop-facebook-app