I want that everyone can send a message to a friend after the user is logged out from facebook.
So I save the access token but when I logout from facebook, then facebook tell me that the token is expired because the user is logged out.
Maybe do I have to request some particular permission ? I know that offline_access permission is deprecated... so what do I have to do ?
This is the error:
"error": {
"message": "Error invalidating access token: The session is invalid because the user logged out.",
"type": "OAuthException",
"code": 190,
"error_subcode": 467
}
P.s. I am using JS SDK but I think that this doesn't matter.
You will have to extend you access token, have a look at this :
http://developers.facebook.com/blog/post/2011/05/13/how-to--handle-expired-access-tokens/
Facebook reference how to handle offline_permissions:
http://developers.facebook.com/blog/post/2011/05/13/how-to--handle-expired-access-tokens/
You should be able to manage.
#Alexandre Couturon Reference :
If you get an Access Token client-side (JS SDK) you will get a short-lived token. You can exchange this token for a long-lived one with the exchange oAuth endpoint:
https://developers.facebook.com/roadmap/offline-access-removal/
Related
I'm trying to get videos of facebook page using facebook graph api.
I get it to work when I use my personal access facebook accounts access token but if I try to use my apps token it returns
{
"error": {
"message": "A user access token is required to request this resource.",
"type": "OAuthException",
"code": 102
}
}
Is there way to get pages public videos from the api by using app token?
If not, is there way to use just my personal access token and renewing it automatically without requiring the user to login. (Server would always make the request with MY OWN access token, not their)
I'm trying to access a facebook page's conversations using the graph api.
Accessing the page itself (with /{page_id}) is fine, but I get on oauth exception for the conversations.
My request in the graph explorer is this one :
/{page_id}/conversations where {page_id} is, well, the page id :)
and the error is
{
"error": {
"message": "(#10) Application does not have permission for this action",
"type": "OAuthException",
"code": 10
}
}
According to the documentation, the required authorization is read_page_mailboxes, which I granted. Here are the rights of my token as shown in the oauth debugger :
public_profile, basic_info, read_page_mailboxes, manage_pages, user_friends
Are there other permissions I'm supposed to require ?
In fact, just asking for the permission itself is not the right way to access to this page informations.
You have to recover the page access token located at /{page_id}?fields=access_token and use this token in order to access the conversations.
I am facing this error with some of my users, the case is as following:
I use facebook "App access token" to post actions to facebook Open Graph instead of the user access token because app access token don't expire according to facebook documentation unless you refreshed the app secret, I use the follwoing Post url to post actions
https://graph.facebook.com/user_facebook_id/App_Namespace:action_name?FBOG_Object=FBOG_OBJECT_URL&access_token=app_access_token
Some of the actions do appear on facebook, but for some users the actions fails to post and return the following message:
{ "error": { "message": "Error validating access token: Session has expired at unix time 1345759200. The current unix time is 1345925578.", "type": "OAuthException", "code": 190, "error_subcode": 463 } }
What am I doing wrong? Why do I have an expiration error although am using the app access token? Should I worry for user permissions?
After checking the servers it seems that the code that uses the app token was not deployed and the code that uses the user token is still there.
The app token does not expire unless the app owner took some action.
https://developers.facebook.com/docs/authentication/applications/
Error message clearly shows that your access token expired and you need to get another one.
However you can handle this issue : Access token expiration
Also if you are looking for a long life token you need to provide some more parameters while authorizing the application to a new user.
offline_access parameter can be included in a request but now it's been deprecated by facebook. Removal of offline access
I'm trying to get the statuses of a facebook page. For this I need an access token, which I can obtain by this:
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&
grant_type=client_credentials
(Found here)
But when I try to access the graph api manually, with the access token, like this: https://graph.facebook.com/id_of_page/statuses?access_token=my_fresh_access_token, I always get this error:
{
"error": {
"message": "A user access token is required to request this resource.",
"type": "OAuthException",
"code": 102
}
}
Are there different 'kinds' of access tokens? Or what am I doing wrong?
There are several access tokens on Facebook.
The access token you are receiving is an app access token which is more limited than the user access token.
The access tokens available are explained here under 'Access Token terminology': https://developers.facebook.com/docs/authentication/permissions/
I have a question, I'm trying to post on a page with the token acquired from
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&
grant_type=client_credentials
I guess the app has permission to post on that page, but when I try to post I get the following error
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException"
}
}
How do I verify the permission?
Basically, I want to be able to post to a page as a page without asking user to login, Would be great if someone can help me out!
The token that you are acquiring is an App Access Token.
And to post on a page as a page itself, you need a page access token.
To get the page access token, you need to make the following API call with an access token with manage_pages permission:
/{page-id}?fields=access_token
this will give you the page access token for your pages. Use that and publish the post.
You can also have a never-expiring page access token. To get one follow this: What are the Steps to getting a Long Lasting Token For Posting To a Facebook Fan Page from a Server