jle
jle

Reputation: 442

What is the difference between a page access token and a user access token

I have been trolling the web trying to figure out why I cannot upload a photo to a album on facebook or on the wall for that matter. Each time I try, I get an OAuthException. I won't repeat my code here because I have already posted that here a few days ago and I don't want to be posting the same question over and over.

So this question is about the difference between page access token and user access token, and most importantly, do I need to use one to upload photos to an album? If so how do I get one?

I think this is related to my original issue since I found this post on facebook: http://bugs.developers.facebook.net/show_bug.cgi?id=13531

Thanks in advance!

Upvotes: 4

Views: 2937

Answers (2)

azureru
azureru

Reputation: 646

You use user access token to read/write as the specified user, the usual https://graph.facebook.com/oauth/access_token will give you the user access token, while for Page access token you can use https://graph.facebook.com/me/accounts

Page access token is used to read/write as a page account (impersonate yourself as a page)

Upvotes: 4

JCPhlux
JCPhlux

Reputation: 455

I am going to quote the Facebook documentation on this one as this is actualy one they where not vague on.

In order to authenticate your app, you must pass the authorization code and your app secret to the Graph API token endpoint at https://graph.facebook.com/oauth/access_token. The app secret is available from the Developer App and should not be shared with anyone or embedded in any code that you will distribute (you should use the client-side flow for these scenarios).

https://graph.facebook.com/oauth/access_token? client_id=YOUR_APP_ID&redirect_uri=YOUR_URL& client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVEIf your app is successfully authenticated and the authorization code from the user is valid, the authorization server will return the access token.

In addition to the access token (the access_token parameter), the response contains the number of seconds until the token expires (the expires parameter). Once the token expires, you will need to re-run the steps above to generate a new code and access_token, although if the user has already authorized your app, they will not be prompted to do so again. If your app needs an access token with an infinite expiry time (perhaps to take actions on the user's behalf after they are not using your app), you can request the offline_access permission.

Upvotes: 2

Related Questions