Using Instagram Graph Api with permanent page access token only works for some accounts - facebook

I try to fetch some images from an instagram business account through the instagram graph api by means of a permanent page access token (facebook: permanent Page Access Token?). These specific tokens seem to be the only possibility to get permanent access to the graph api for a server-side app.
On the other side I found a hint in the fb documentation that only user accesss tokens can be used to access instagram business accounts.
"Page access tokens are not supported."
https://developers.facebook.com/docs/instagram-api/overview/?locale=en_US
Funny enough I was using page tokens so far without any problems. After resetting the database of my project and generating new tokens I observered that some accounts weren't able to fetch the data while others had no problems.
"Unsupported get request. Object with ID 'XXX' does not exist, cannot be loaded due to missing permissions, or does not support this operation."
I had 2 instagram accounts: 1 was working with page access tokens the other didn't. So, I checked it in the fb graph explorer. Using the user access token I have no problem with both accounts. Using the page access token respectivly for both accounts one is working fine for the query while the other isn't. A third account that I created has the same problem.
Things I tried to resolve the issue:
deleting all permanent page access tokens from my database and generate them again
generate the permanent page access tokens manually by means of the fb graph explorer tool
turn my instagram account back into personal and then again into a business account through the app
turn my instagram account back into personal and then again into a business account through the facebook page
create a new instagram account and a new facebook page to connect (repeating 3. and 4.)
My questions now:
Can I use permanent page access tokens for the instagram graph api?
If not, how do I get permanent server side access to the instagram graph api?
I am now searching the internet and stackoverflow for days and getting crazy because I seem to be the only person experiencing this problem. So, help will be highly appreciated by my fellow developers. Tia.

Since yesterday everything works fine again also when using the permanent page access token. Seems like fb resolved an internal bug. However, the question remains, if page access token can be used in general or if it is just a bug itself.

Related

Request data from Facebook Graph API with multiple different tokens

I request data from my companies facebook page via the Facebook Graph API. I have created a page access token which has multiple rights. With this token I can read multiple statistical facts showing the performance of the facebook page.
According to the page access token description the token is connected to my user account. I am currently an admin of the facebook page of my company. Currently I share the page access token with my colleges.
Problems:
What happens if I am not the admin of the page anymore (e.g. I leave my current company).
What happens if I delete my facebook account some time in the future?
I would like to have multiple access tokens in order to use a backup token if neccessary
What would be the right way to do this?
I know there is sth. like an app access token (see link above).
I think there is only ONE unique app access token. Can I create multiple tokens?
Is there a proper way to handle my problem?
Is the page access token (which I currently use) coupled with my private facebook account? That would be bad!

Facebook insights via graph.facebook.com authentication flow

I am trying to programatically grab a few insights metrics from facebook for various pages (about 50 clients). Therefore I want to automate this.
I created a facebook app and have my app_id and app_secret. I also created a app_access_token which doesn't expire?
My question is this: How do I get the page access token for each of the pages I want to get insights from? Currently I...
STEP 1) ...went to the Query Explorer and seleted my app and grabbed a user_access token with the manage_pages and read_insights permissions.
STEP 2) I then used that user_access_token to go to https://graph.facebook.com/v2.5/{pagename}?fields=access_token&access_token={user_access_token} to get what I presume is the page_access_token.
STEP 3) I then use this token to do my queries for things like https://graph.facebook.com/v2.5/{pagename}/insights/page_impressions?access_token={page_access_token}.
Now since the app is already OKAYed, shouldn't be there a way to grab that user_access_token in step 1 programatically? They all expire except the app_access_token I described above. Can I use that token somehow in step 1?
I am not using and SDKs just pure https calls.
Actually it is possible. I managed to get an extended page access token by doing this:
https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=[app-id]&client_secret=[app-secret]&fb_exchange_token=[short-lived-token]
from here. Basically you get a short lived user token and then use that to get a page access token and then use that with your app id/secret to get an extended page token that never expires (perfect for embedding in an automated reporting app).
It is convoluted but it works. And as a bonus if you register the APP on Facebook business manager, that page token will work on all sites you have access to under that business manager account.

Differentiating between 'personal' facebook API key and 'Business Page' API keys

I am building a website and want to transfer over the data of a business Facebook page (posts) and put it into a 'social wall' so to speak on the website, using the Facebook API. The problem that I am having is that it is copying the data from my own personal Facebook account, rather than the Facebook 'business pages' account. I can't seem to change it!
How can I make the Facebook API differentiate between my 'personal' facebook API key and the 'Business Page' API key, and thereby transfer the data from the business page rather than my personal page?
I assume that what you're trying to do is use FB API to get post from a FB page and then display that into a website. After that, I guess you're planning to allow comments and some kind of interaction from there.
The issue you're facing is likely that when you use the API, you're getting back posts from your personal account instead of the page you want.
If so, the problem is the access token you're using.
To work with FB Graph API, you need an access token for every request, the access token will identify the person making the call.
You can learn more about access tokens here:
https://developers.facebook.com/docs/facebook-login/access-tokens
That said, I think there might be two different issues here:
You're calling me/posts using your user access token. That will get you back your own posts.
You're calling [your_user_name]/posts with a page access token, That will also give you your own posts.
You can see page posts that are public using your own access token and for the rest, you need a page access token.
If you're admin of the page, you can query me/accounts and you'll get the page access token for your page. If not, you'll need to go to business manager and get it from there.
If non of these options are available for you is because you have no access to this FB Page and therefore, you're not allowed to do this.

No access token facebook application authentication

I'd like to show my facebook wall posts on my website.
So i don't want to authenticate users with a dialog, to grant them some rights, i just want to show him my wall with comments (no ability to add comment just read only access).
As i know there isn't unexpired tokens now so is it possible to access just my data without requesting token every time it expires?
I'm using asp.net mvc but i think this sultion doesn't depend at platform at all.
You should:
Make your Facebook Posts public
Call the API endpoint: https://graph.facebook.com/{your_id}/feed?access_token={app_access_token} with your user_id and valid application access_token
Show the results on your website.
The App Access Token doesn't expire so you won't have a problem. As long as the posts are public, the API will be able to pick them up. In theory, your posts should be public anyway so anonymous users can see this.
This also gives you the ability to share stuff privately and not have it show up on your website.

2 different types of user facebook access tokens?

I have set up a facebook app so people can post stuff from my site directly to facebook using the graph api.
I request offline access and manage_pages so that they don't have to be logged in to facebook, but just to my site.
I also have set up the ability to post to a fan page they are managing directly from the site.
both those things definitely work because i have a fan page and i authorized it on my site and am able to post stuff to it directly from my site.
the problem is that when i send the access token to facebook /accounts?access_token=XXX, nothing is being returned for some users even if they are definitely managing (they sent me a screenshot showing they were the manager of the page)
looking at the access tokens i noticed that mine looks like (this is fake):
200785063253279|561ec27497172e3ddvs32dsc.1-10002342352350235|kB2_OoBtsgscsVW2mKMijfNdvb0
while the users in question have an access token like (again - fake):
AAAC2nOrFTH0BAJjMgS3h22ADhirwsfweRT35235LGcZCGisrefwae5tSF535DGlLKJOIBMnrMnI324sfasdSFOIjo325sIigfWOE1aNbvd8wAZD
I can't help but notice the vast difference between the two. is there a reason? is that why i am not getting any page info when i send the request to facebook?
Any help is appreciated!
The first Access Token is the old access Token format and the second Access token is the new Access token format.
This new format was announced a year ago:
https://developers.facebook.com/blog/post/497/
And rolled out last September:
https://developers.facebook.com/blog/post/2011/09/09/platform-updates--operation-developer-love/
Any new Access tokens you get from the system will be of the new format.