Unable to perform Graph user search using API Explorer - facebook-graph-api

I'm having an issue getting the graph search to work when I manually use the Graph API Explorer to generate an access token for myself against my application.
I've created an application, set the sandboxed mode to 'off', and then manually granted my user account permissions to my application. To be safe, I included all the permissions available in the graph API explorer before generating the access token.
When I click on my access token, I see that it is still valid, and has all the permissions listed, however, when I perform the following search:
/search?q=myphonenumber&type=user
I get an error saying:
{
"error": {
"message": "(#200) Must have a valid access_token to access this endpoint",
"type": "OAuthException",
"code": 200
}
}
I know the above search code is valid because I was able to get it working a few days ago, I can't seem to figure out what has changed. Am I missing a permission somewhere that prevents me from using my access token to do an API search?
UPDATE: I should also mention that normal /me queries work just fine, it seems to be only the search which is disallowed.

I got the same problem when searching for email addresses using the same search term. While researching the problem, I found this bug report: https://developers.facebook.com/bugs/453298034751100?browse=search_516534c213df06064266897. So Facebook is aware of the problem but nothing has changed for more than a week now.

Related

Authorised Exception using access code which never expires

Using the Facebook Access Token Debugger I can see I have an access token that never expires.
https://developers.facebook.com/tools/debug/accesstoken/
However using the Graph Explorer I get the error
{
"error": {
"message": "(#10) To use 'Page Public Content Access', your use of this endpoint must be reviewed and approved by Facebook. To submit this 'Page Public Content Access' feature for review please read our documentation on reviewable features: https://developers.facebook.com/docs/apps/review.",
"type": "OAuthException",
"code": 10,
...
}
}
This was previously working, has something changed with Facebook? The only other thing that has changed is that my access to the Facebook App was removed then reinstated, so I now use a different access code.
Please could anyone advise what I need to do to resolve this issue, I previously did not need Facebook review to use this API last month.
Thanks
Edited: the login required screen when requesting a Page Access Token:
This is not about expiry of the token.
Facebook has restricted API access to the data of any public pages - you now need to get your app reviewed for the use of the feature “Page Public Content Access”, before you can use it.
https://developers.facebook.com/docs/apps/review/feature#reference-PAGES_ACCESS
Without getting this reviewed, you can only access data from pages you have admin access to - but that in turn requires the use of a different kind of token then, a page access token. (You presumably used the general app access token, for your requests that have been working up until now. For that to keep working to access public page data, you need to submit for review of the feature.)
Thanks to misorude for all your help. This is what worked for me:
Step 1: ask the business manager to grant the user "Manage Pages" permission on both the app and the page:
https://business.facebook.com/settings/pages/PageID?business_id=BusinessID
https://business.facebook.com/settings/apps/AppID?business_id=BusinessID
Step 2: Create the user access token (select "Get User Access Token" from the "Get Token" dropdown)
https://developers.facebook.com/tools/explorer/
Step 3: Check the user has access by calling your graph method using the temporary user access token
E.g. https://graph.facebook.com/v3.3/PageID?fields=link%2Cpicture&access_token=UserAccessToken
E.g. https://graph.facebook.com/v3.3/PageID/feed?fields=message%2Cfull_picture%2cpermalink_url%2Ccreated_time&limit=3&access_token=UserAccessToken
Step 4: Create permanent user access token
https://developers.facebook.com/tools/debug/accesstoken/
Click "Extend Access Token" at the bottom of the page and debug to reveal the token with expiry: never

What does it mean "error_subcode": 33 in the facebook response error?

Does anybody know what does it mean error_subcode: 33 in the facebook response error? I know it's related to a mission permission but I want to be 100% sure.
We received the following error:
{"error":{"message":"Unsupported get request. Object with ID 'XXXX'
does not exist, cannot be loaded due to missing permissions, or does
not support this operation. Please read the Graph API documentation at
https://developers.facebook.com/docs/graph-api","type":"GraphMethodException","code":100,"error_subcode":33,"fbtrace_id":"BRwGjA9kkKU"}}
But in the Facebook API documentation about Graph API https://developers.facebook.com/docs/graph-api/using-graph-api/ , I cannot find error_subcode with value 33.
I want that I can rely on this subcode to verify that I don't have permissions to get the resource from Facebook API because I don't want to rely on the error message.
Here is the Facebook bug portal link to the similar issue:
https://developers.facebook.com/bugs/316526372199563/
The gist of it is:
these users registered for Facebook/Messenger using their phone number and such users are not yet queryable by the API. This is on the roadmap for the API, please keep an eye on our changelog for when this goes live in a future version: https://developers.facebook.com/docs/graph-api/changelog"
I can't offer a definitive solution, as there seem to be multiple possible causes. However, I encountered this today and wish to offer this possible cause.
If you are encountering this error when you are testing your Facebook TEST app, it might be related to the fact that you're in TEST app mode.
In my case, I worked on implementing Facebook login for a while. When my partner joined in development, he couldn't log in in his development environment. He got the error you mention for the 'me' endpoint:
{
"error": {
"message": "Unsupported get request. Object with ID 'me' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"error_subcode": 33,
"fbtrace_id": "____"
}
}
This had actually already been deployed and tested to our production environment, where we are both able to register and log in just fine.
After I added him as Administrator to the Facebook TEST app, the issue resolved and he could register and log in on his own development environment.
So, you may want to check if this is applicable to you. An easy way to check is to use the keys for the real app in your development environment.
Error subcode 33 information as per Facebook official documentation:
Error code 100, subcode 33
Unsupported post request.
This error may occur if your access token is not added as a system user with appropriate permissions to the ad account that owns a Custom Audience. Verify the ad account in Business Manager and verify all system users appear under the ad account as Admin:
Click on Business Settings
Click the ad account
Select Add people
Search for system user and add them as Admins
Retry your API call
Here's the link to the Facebook marketing API error reference.
https://developers.facebook.com/docs/marketing-api/error-reference/
This contains the resolution for error 33 along with all the other errors.

Facebook Reach Estimate - not suficient permissions

I am trying to follow an example on Reach Estimate in facebook API documentation here. However I am getting an error:
{
"error": {
"message": "(#10) You do not have sufficient permissions to perform this action",
"type": "OAuthException",
"code": 10
}
}
My approach is to open https://developers.facebook.com/tools/explorer, generate a token giving all permissions including ads_management.
And perform call:
act_ID/reachestimate?currency=EUR&targeting_spec={'countries':['US']}
Where I obtain ad account ID by going to my ads manager and reading it off URL (or by visiting power editor).
It looks simple, but I have no idea at this point what I am missing, I am also getting the same error while using PHP API.
All ideas are much appreciated. Thank you.
If you are using your own app to generate the access token, you are likely on the Standard or Basic tier of the Marketing API. For these tiers, you need to specify each AdAccount you are going to use.
In the developer too, select your app and go to Apps > Settings > Advanced. Under "Advertising Accounts" click the "Ads API" button on the right hand side, and list all the accounts you want to use.
For more info, see:
https://developers.facebook.com/docs/marketing-api/access#standard_accounts

Posting scores with app access token

I'm trying to post a score from my server.
I have my app set up as a game.
I've got my app access token.
I'm POSTing to https://graph.facebook.com/USER_ID/scores
I have authorized and given publish_stream and publish_actions permissions to my app for the USER_ID (which is me).
However, an error is telling me that I need a user access token for that action, which I don't as Facebook states here: https://developers.facebook.com/docs/score/
Create or update a score for a user
You can post a score or a user by issuing an HTTP POST request to
/USER_ID/scores with the app access_token as long as you have the
publish_actions permission.
I've seen a similar question but it was unanswered: Facebook Graph API Explorer won't POST scores (they've ended up creating a new app, which is not a real solution)
To verify that it's not me who is incorrectly using the API, I went to Graph API explorer and tried it also there with the same access token, no luck:
Funny, that if I follow what it says and try the same with my user access token, it then says: This method must be called with an app access_token.
Is there something that I'm missing or is there a bug with the Graph API?
Thanks,
Can.
It looks like you have everything correct, but there's one relatively little-known case which will produce that error message.
Check the 'App Type' field in the Advanced Settings:
If this is set to 'Native/Desktop' instead of 'Web' in the Advanced settings, it's assumed that your app's binary/native distribution contains the app secret.
In this configuration, API calls made with the app access token are untrusted, effectively the token is completely ignored.
Change the app settings back to 'Web' and you should be able to post or delete Scores and/or Achievements with the App Access Token
If this is the issue, you can quickly verify if with a call to
https://graph.facebook.com/app?fields=migrations&access_token=[APP ACCESS TOKEN HERE]
In 'Web' mode, the response contains the migration settings for the app, something like:
{
"migrations": {
"secure_stream_urls": false,
"expiring_offline_access_tokens": false,
"requires_login_secret": false,
//etc
}
In 'Native/Desktop' mode, the app access token is untrusted, so you can't access the app's private data, and the response is:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}

Facebook Graphi API does not list page accounts in offline mode

My offline Facebook application is trying to retrieve the accounts associated with a specific user id who has previously authorized the application:
https://graph.facebook.com/(userid)/accounts?access_token=(token)
Even though I am passing a valid access token, Facebook returns:
OAuthException: An access token is required to request this resource.
I verified that my access token is correct by querying the likes connection with the same userid and access token:
https://graph.facebook.com/(userid)/likes?access_token=(token)
For this second statement, Facebook returns the expected result.
My application has manage_pages and offline_access permissions. The access token I am using is the access token Facebook returned when the user authorized the application. I don't understand why it works for the likes connection but not for the accounts connection.
Facebook provides different access tokens, some are shorter and some are longer. Without realizing the difference, I had used the shorter ones, created as type='client_cred'. These work fine for retrieving friends lists, lists of fan pages, publishing to stream etc. but apparently they do not work for getting accounts information.
Here is an example of both types of access tokens. Apparently the first one lacks session information (which is the middle part of the second access token).
116122545078207|EyWJJYqrdgQgV1bfueck320z7MM.
116122545078207|2.1vGZASUSFMHeMVgQ_9P60Q__.3600.1272535200-500880518|EyWJJYqrdgQgV1bfueck320z7MM.
If your access token is wrong facebook returns this:
{
"error": {
"type": "OAuthException",
"message": "Error validating access token."
}
}
It seems that the token is not passed to the graph api. Depending on which SDK you use to pass the token, there are different errors that can occur. The PHP SDK for example ignores the token you pass and tries to get the token from the session cookie, which causes errors. Could you clarify how are you making the graph api calls?
I have verified that with a valid token you can get the accounts data. Have you tried pasting this into your browser https://graph.facebook.com/(userid)/accounts?access_token=(token)?