Facebook ID Matching API says invalid token - facebook

I have an app in firebase where the user logs in with Facebook. From that login I get his ASID. Now I want to get this users ID in my messenger and write him a message.
I followed this tutorial: https://developers.facebook.com/docs/messenger-platform/identity/id-matching
My URL looks something like this:
https://graph.facebook.com/v5.0/{ASID}/ids_for_apps?access_token={pageAccessToken}&appsecret_proof={sha256}
To get the pageAccessToken:
https://graph.facebook.com/v5.0/{pageId}?fields=access_token&access_token={userAccessToken}
Now I get this error:
{
"error": {
"message": "(#100) Invalid token. Can only query using page access tokens where the page is owned by the same business as the app.",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "ACv6_We47HagGtMBzrQuT5A"
}
}
Does anyone know what I am doing wrong?
In the developer page for my App, I have linked the sites (Settings > Extended > App Pages)

Related

Creating a Test Page For a Test User in Facebook Graph Explorer

I'm trying to create a test page for the test user i created in my Facebook application portal, i added the manage_page permission to the test user and aquired an access token as mentioned in the documentation.
However, i'm using the Facebook graph explorer to make a post request to user_id/accounts with the following parameters:
**name** Test Page
**about** This is a test page
**category_enum** LITERARY_ARTS
**picture** https://upload.wikimedia.org/wikipedia/commons/3/36/Hopetoun_falls.jpg
**cover_photo** http://healthhub.co/wp-content/uploads/2014/02/Group-Slider.jpg
i'm getting the following invalid parameter error on the cover picture , i tried to encode the URL but didn't help.
{ "error": {
"message": "(#100) Params cover_photo with a valid URL is required for creating a page",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "A35OXtKL8zh" } }
cover_photo is an object that expects the URL parameter and the URL as value:
{
"url": "<URL VALUE>"
}

Facebook: get event information for public page

My Facebook page publishes public events and I am developing an app that uses this page. I want to get the number of interested/going people for a specific event given its Facebook id.
I, the creator of the app, am also the admin of the page. However, using my app access token that I generated with the app id and the app secret, I can't call the event API: https://graph.facebook.com/v3.0/137340177139954?access_token={access_token}
I get the following error
{
"error": {
"message": "Unsupported get request. Object with ID '137340177139954' 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": "FqJ5oAqdukA"
}
}
What am I doing wrong? How do I get event information about a page that I own
The endpoint that you're hitting is not correct. You're forgetting the /events portion after your page_id.
This is what it should look like:
https://graph.facebook.com/v3.0/137340177139954/events?access_token={access_token}

Can you get a page access token for a page you do not own, ie you are a third party ? (FB insights)

Would like to use these FB Graph API insights endpoints for the Nike FB page.
https://developers.facebook.com/docs/graph-api/reference/v2.12/insights
But, every time I go to the developers.facebook.com tools and generate a new "Page Access Token" and then try to type in the endpoint, I get this error:
{
"error": {
"message": "(#190) This method must be called with a Page Access Token",
"type": "OAuthException",
"code": 190,
"fbtrace_id": "CWg3K5qBxk+"
}
}
Page Tokens are for Page owners only. Think about it this way: Would you be able to get access to Google Analytics of some website you do not own? Of course there is also no way to access the Facebook Insights of a Facebook Page you do not own.
I believe you cant get access to info insights.
However you can get some info from the API
For instance:
'Nike?fields=fan_count,pharma_safety_info,phone,description'
returns:
{
"fan_count": 32788277,
"description": "Just Do It. ",
"id": "15087023444"
}

facebook ads api - read other account campaigns

I am using Facebook ads api to read campaign from other account. I have created the application, got app_id and app_secret. In graph explorer, I am using other person's access token and account id to get his campaigns. But facebook gives me following error:
{
"error": {
"message": "(#274) The ad account is not enabled for usage in Ads API. Please add it in developers.facebook.com/apps -> select your app -> settings -> advanced -> advertising accounts -> Ads API. Account 1817273581872129 not enabled for this application.",
"type": "OAuthException",
"code": 274,
"fbtrace_id": "GW38TMsIi1v"
}
}
I did followed error instructions but still the same problem.
here is the url i am using in graph explorer:
act_12345566654/campaigns
However, when I use facebook ads api in python:
I get the following error:
FacebookRequestError:
Message: Call was not successful
Method: GET
Path: https://graph.facebook.com/v2.8/act_1817273581872129/campaigns
Params: {'summary': 'true'}
Status: 400
Response:
{
"error": {
"message": "Invalid appsecret_proof provided in the API argument",
"code": 100,
"type": "GraphMethodException",
"fbtrace_id": "FRdlngO8f04"
}
}
Here is the code:
session = FacebookSession(self.app_id, self.app_secret, self.access_token)
ads_api = FacebookAdsApi(session)
adaccount = AdAccount(self.account_id, api=ads_api)
campaigns = adaccount.get_campaigns()
Where am I going wrong ? Kindly assist me
Most likely, the app secret that you have provided doesn't belong to the app id or the access token that you are using doesn't belong to the right app.
Check the following:
1) The app id
2) The app secret (should be of the specific app)
3) The access token (should be for the app specified above)
In case you still need it - in the explorer you must haven't selected the app. This is on the top right corner. By default, it sets the app to Graph Api Explorer, click on the drop down menu, and choose your actual app.
Cheers!

App access token, can't get user information

When I try to use the already generated access token, on this https://graph.facebook.com/4921782178422?fields=id&access_token=ACCESS_TOKEN, it gives me this in response:
{
"error": {
"message": "Unsupported get request. Object with ID '4921782178422' 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,
"fbtrace_id": "F2ot2MGcBBM"
}
}
Facebook writes that all access tokens have permissions to public_profile, but i can't use the link above.
4921782178422 is a user id.
It works fine, when I use my own user access token, but that's only valid for 1 hour, and I need it longer than that.
I have followed these steps:
facebook: permanent Page Access Token?
What do I do wrong?