I'm using the unofficial python sdk for Facebook. This works fine for alot of graph api calls, but my recent project requires using more FQL. Certain tables (notifications for example) require a user access token rather than an app access token.
When using
graph.facebook.com/oauth/access_token?client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&grant_type=client_credentials
it seems I only get an App token back. So when calling the notification table I'll receive a "102 : A user access token is required to request this resource"
This project does not use a browser at all, and is mainly created to validate notifications, and postings generated from another app.
Whats the best way to receive a user token in this case?
Thanks N
You can not get a user access token without a direct interaction of a logged in user with your application using the facebook authentication flows. The only token that can be obtained without a user is the application token and you've got that covered already.
You can create a user token manually, the easiest way, I think, would be to use the Graph Explorer tool. Just select your application on the top right, then click the "Get Access Token" button, you can then check the needed permissions and after that a generated token will appear in the text box, copy that and use it.
The problem with that is that the access token is a short lived one (a few hours), if you need a longer one I suggest that you create a canvas application that will only implement the Server-Side authentication which will end with a long-lived token (60 days), then you can persist it and use it for that time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With