/accounts/test-users giving OAuthException - facebook

For some reason, I'm suddenly having trouble accessing my test users via the graph.
GETting this ...
https://graph.facebook.com/229607217115781/accounts/test-users&access_token=MYAPPACCESSTOKENHERE
Gives me:
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
MYAPPACCESSTOKEN has been generated by calling
https://graph.facebook.com/oauth/access_token?client_id=MYAPPID&client_secret=SECRET&grant_type=client_credentials
and it returns the token just fine.
Looking at my git history, I'm pretty sure that this has worked before, making me suspect it's some breaking change I'm not aware of.

If your app is marked as a 'Desktop' app; you can't use the App Access Token for app administration via the API because it's assumed that you've distributed the app access token with the application binary and thus it can't be trusted as any of your users can decompile the app and get the app secret that way.
You can still use the Administration interface on developers.facebook.com for managing test users, or you can set your app back to 'Web' mode and the app secret will be usable for that call again

Related

Missing permissions error while trying to fetch ads data using API

We have an App that is connected to several advertising accounts. In the past, we used to use the app internally by our developers to fetch the ads data and use it internally for monitoring analysing purposes. We used to face some token expirations issues from time to time (we use long living user token) but we refresh the token and our job is able to refresh the token.
However, in the last month, our token is expired, and when we refresh the token and we try to fetch the data, we get the error: "(#100) Missing permissions".
Status: 400
Response:
{
"error": {
"message": "(#100) Missing permissions",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "-"
}
}
Despite that the permissions we are giving to our app are: read_insights, ads_management, ads_read, public_profile, and in the past used to work fine, but suddenly it's not working anymore.
We did some investigations, we found a lot of issues like those, but we couldn't find a solution. Also, our app is used internally within the company, by developers to fetch Ads data. Are we missing anything here? Can submitting an app review be a solution for the problem?

Facebook Ads Insights API: (#3) Application does not have the capability to make this API call

I am trying to pull Facebook Ads metrics through the Facebook Marketing API. The flow is basically that I wish to pull all the account ids of my company, and then loop over them, retrieving the insights for them individually.
However I have an error which I am not able to solve/comprehend.
When I attempt to make the API call (both in the Graph Explorer and my Alteryx workflow):
GET-> /v2.8/act_<Account_ID>/insights
I get the following error:
"error": {
"message": "(#3) Application does not have the capability to make this API call.",
"type": "OAuthException",
"code": 3,
"fbtrace_id": "BNevVWUExDg"
}
I must admit that I am quite at a loss what is causing this error...and actually also exactly what the issue is...am I lacking the right scope/permissions for my token?
With the same token I am able to correctly call the API to get a list of all adaccounts (GET-> /v2.8/me/adaccounts ).
Anyone have an idea what my issue might be?
You have to make sure that your particular access token has the permissions ads_management or ads_read.
This is from the Marketing API quickstart. https://developers.facebook.com/docs/marketing-apis
There are also rate limits on those API's, but I would expect a different error if that was the case.
I ran a POST instead of GET on the same endpoints, which gives me another error about not being admin on the account.
It appears that the user associated with the token (which is a long lived one) was only having analyst access to the account in Business Manager. After I changed it to advertiser it seems I can do the GET call.
In my case, I added a new development user in the roles page. Then I was trying to do OAuth. I got the error message "Application does not have the capability to make this API call."
Here's the way that I solve the problem while your application still in the development mode.
Go to Marketing API > Tools
Then select what token permissions you want. Press "Get Token" button.
Now, you can try to do OAuth again.

Facebook Graph API "/{page-id}/feed" is not working with App Access Token

We are facing issues with Graph API. The Facebook Graph API "/{page-id}/feed" is not working for all pages with a valid App Access Token. Previously it used to work. We noticed it today the API is throwing error
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
Not working pages:
https://graph.facebook.com/22934684677/feed?access_token=
https://graph.facebook.com/42798291365/feed?access_token=
Note: And its working if we pass a User Access token instead of App Token.
Facebook developer Docs says "An access token is required to view publicly shared posts." So App Access Token should work!
Does Facebook change something inside the API?. Can any one help to solve the issue
You should use a Page Token for Page data. Pages not working with an App Token are most likely restricted by age or location. Since the App Token does not include any user session, you canĀ“t be sure if the user should have access to it.
If it does not work with an App Token AND the Page is definitely not restricted, file a bug.
This is happening because some of the posts returned might have extra restrictions on them which need a user token to verify this. Use a page token or a user token as a workaround for this. Having said that, the request shouldn't fail with an unknown error and we're working on a fix for the same on the bug report here:
https://developers.facebook.com/bugs/783169051760311/

Facebook open graph says access_token needed

I'm trying to post the following the facebook Graph API explorer.
cody.short.94/notifications? access_token= {User Access Token} &template= this is a test &href= www.test.com
I want to be able to send the user a notification, but all attempts have failed. I'm currently getting this error:
{
"error": {
"message": "(#15) This method must be called with an app access_token.",
"type": "OAuthException",
"code": 15
}
}
I'm not sure what is causing it, and I'm in need of some guidance. Any help would be appreciated. note: my app is currently marked for web so that it not the problem
See, the error is quite self-explanatory :
This method must be called with an app access_token
The Notifications API use the APP Access Token, not the user access token!
The App Access Token is: APP_ID|APP_SECRET or get directly from here for testing. (Make sure of the security of this token, this is very crucial and just like a password to your app)
Now test the query with Graph API Explorer , and remove the user token from the Access token field and replace it with the App Access Token
It will look something like this-
Make sure you paste the app access token APP_ID|APP_SECRET on the top field that says Access Token

App Access Token can't retrieve Test Users?

I can't get the list of my test users with my app access token. First I get the app access token with the following graph api call:
https://graph.facebook.com/oauth/access_token?client_id=APP_ID&client_secret=APP_SECRET&grant_type=client_credentials
which succeeds, I get an access token in the format
APP_ID|SomeRandomCharacters
Now I try to get my list of test-users using the following graph API call:
https://graph.facebook.com/APP_ID/accounts/test-users?access_token=APP_ACCESS_TOKEN
however, I get a "bad URL" error in my iOS code.
If I try to go to that address directly in a browser I get HTTP 400 Bad Request and if I try it in the Graph API explorer, I get
{ "error":
{ "message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104
}
}
Check your app isn't defined as 'Desktop/Native' - if it is, your app secret is considered untrusted for API calls that can change the app's settings (including Test Users)
The assumption is that the app secret has been distributed with your native app and can't be trusted.