Retrieving pages for a newly created admin user of a page returns empty - facebook

My applicaton uses this endpoint to retrieve a list of pages to which a user has access.
For my personal account, which is the admin of a page, it works fine:
https://graph.facebook.com/me/accounts?access_token=[accesstoken_for_my_personal_profile]
Results:
{
"data": [
{
"access_token": "<the access token>",
"category": "Record Label",
"name": "Page Name",
"id": "Page ID",
"perms": [
"ADMINISTER",
"EDIT_PROFILE",
"CREATE_CONTENT",
"MODERATE_CONTENT",
"CREATE_ADS",
"BASIC_ADMIN"
]
}
]
}
But when we create a totally new facebook profile (regular user, as per my personal one) - and get it verified using mobile phone / SMS based verification, it only ever returns blank here, despite being given page admin access to the same page and having requested an access token exactly the same way:
https://graph.facebook.com/me/accounts?access_token=[accesstoken_for_newly_created_profile]
{
"data": [
]
}
UPDATE
The access token permissions are also different.
So when calling https://graph.facebook.com/me/permissions?access_token=xxx, the bad user only has public_profile and installed as 'granted' - but the good user has all the requested permissions including 'manage_pages'.
The URL used to request the tokens in the first place is here:
https://www.facebook.com/dialog/oauth?client_id=[my_app_id]&redirect_uri=https://www.facebook.com/connect/login_success.html&scope=manage_pages,read_mailbox,read_stream,publish_actions,user_likes&response_type=token
This directs to a login page which logs in as the user for which we want a token.

Courtesy of #CBroe above:
The issue here was that since API v2.0 came in, requesting access tokens for users who do not have a role in the requesting app will not assign certain permissions (in our case 'manage_pages') unless the app has been reviewed.

Related

Missing attributes with Facebook Graph API Photo Node

I have an access token with the manage_pages scope. Using this token, I call the endpoint specified here (GET /{page-id}/photos?type=uploaded).
The result is for some reason lacking all attributes except id and created_time. This is a part of the response:
"data": [
{
"created_time": "2018-10-30T18:12:31+0000",
"id": "1172525292900120"
},
{
"created_time": "2018-10-30T18:10:08+0000",
"id": "1172524459566870"
}
]
The docs says that data should contain "A list of Photo nodes". Looking at the photo node docs, it seems they have exactly what you'd expect.
My app does not have the permission Page Public Content Access yet. But according to their App Review section, it isn't needed for accessing my own page's content. And then again, I wouldn't even be able to get a list of photos if I didn't have access to the page.
While you are testing your app and before you submit it for review, your app can only access content on a Page for which the following is true: The person who holds the admin role for the Page also holds an admin, developer, or tester role on the app.
Why am I missing some attributes in the Photo nodes?
I had to specify which fields to retrieve like this: GET /{page-id}/photos?type=uploaded&fields=images.

Facebook API V3 - Create Facebook Page for Test User

I have an application that uses Facebook login module.
I tried to get manage_page and publish_page permissions but Facebook is not giving these permission without review. So, I tried to create test user and gave him above permissions.
Then logged into Facebook with test user. Facebook is not letting test user to create facebook page.
I need to access user's pages but cannot do because I cannot create at the first place.
I got the access_token of the test user and called facebook api with following json. And then I can see my test user had created page when I login to facebook.
/me/accounts
{
"name": "Your Page Name",
"category": 2211,
"about": "Description",
"picture": "your_page_picture_url",
"cover_photo": {
"url": "your_page_cover_photo_url"
},
"classic": 0,
"city_id": 2505639
}

Verify Access Token Facebook?

I am wondering how to verify the access token that facebook generates on login in my server? Also what information it contains
I followed this page and did this
https://graph.accountkit.com/v2.7/me/?access_token=
but when I put my token in it says it is invalid oauth token
when I use this one I found
https://graph.facebook.com/app?access_token=
it brings back
{
"category": "Lifestyle",
"link": "http://localhost:3333/",
"name": "testapp",
"id": "2"
}
I am not sure if that is valid enough. I was hoping it would bring back user data as well.
Edit
I am using this react plugin to do the facebook login it comes back with
accessToken: ""
email:""
expiresIn:4863
id: "" // think this is userId as it is the same numbr as UserId Field?
signedRequest:""
userID:""

Page access tokens from web app

I'm writing a facebook web app with Graph API for publishing on a page wall automatically. I'm the page administrator and I've set up the app permissions for requiring manage_pages, offline_access, read_stream and publish_stream. My app will be like twitterfeed app with something different (I've no rss feed as a source).
For the first step I call:
https://graph.facebook.com/oauth/access_token?client_id=".$app_id."&client_secret=".$app_secret."&grant_type=client_credentials
When this call return an access_token I call:
https://graph.facebook.com/100344706779072?fields=access_token&access_token=". $access_token
Here I have problems: as facebook doc says (https://developers.facebook.com/docs/reference/api/page/#page_access_tokens) I must get page_access_token in this way, but this call return only the page id..
So what I'm doing wrong?
From the facebook docs here: https://developers.facebook.com/docs/howtos/login/login-as-page/
you need to use the access token you got in the first call and make a second call to https://graph.facebook.com/me/accounts?access_token=$access_token
and you'll get a reply that looks like this:
{
"data": [
{
"name": "PAGE_TITLE",
"access_token": "PAGE_ACCESS_TOKEN",
"category": "PAGE_CATEGORY",
"id": "PAGE_ID"
},
{
"name": "PAGE_TITLE",
"access_token": "PAGE_ACCESS_TOKEN",
"category": "PAGE_CATEGORY",
"id": "PAGE_ID"
},
...
]
}

How to get a Facebook access token that has enough rights to get the posts in which you're tagged in?

The Facebook posts in which you're tagged in - using #Name - appear in your wall feed.
A friend of mine posted a link and tagged me in it:
On the Graph API documentation, when I click on my wall feed link (Ctrl + F: Profile feed), I'm able to see this post:
...
{
"id": "XXX",
"from": {
"name": "XXX",
"id": "XXX"
},
"to": {
"data": [
{
"name": "XXX",
"id": "XXX"
},
{
"name": "Christophe Maillard",
"id": "XXX"
}
]
},
"message": "The startup Guide (cc XXX, Christophe Maillard)",
"link": "http://mashable.com/2012/06/27/startup-guide-1000-users/",
"name": "How to Get to Your First 1,000 Users",
"caption": "mashable.com",
"description": "With the help of some smart marketers and entrepreneurs, we're created a clear outline for attracting your startup's first 1,000 users.",
...
}
...
The URL of this feed is https://graph.facebook.com/me/feed?access_token=XXX.
When copy/pasting the given access token - the one replaced by XXX in the URL above - within the debugger, I get something like this:
As we can see, the access token is generated by the app Test_console which used quite a lot of scopes.
Then, I go to the Graph API Explorer, I generate an access token using the Get Access Token button, and I specify all the scopes the debugger gave me, i.e. the ones the Test_console app used to generate its working access token. Finally, I access the URL me/feed by submitting the GET request. The problem: I can't see the post in question in which I'm tagged in with the explorer.
I also have my own app, and it reacts exactly like the Graph API Explorer: I can't find that post in my wall feed using the Graph API as well.
Obviously, it's possible to get the posts in which you're tagged in using the Graph API, because the Test_console app is able to generate an appropriate access token. But how can I get such an access token for my own app?
You need to grant the appropriate permissions for your app. In the graph api explorer https://developers.facebook.com/tools/explorer?method=GET&path=me switch to your app in the applications field (top right) to see what permissions that currently grants your app (by clicking the "get access token" button again). Then make sure you add in the correct one (i think it's read_stream you're after ) https://developers.facebook.com/docs/authentication/permissions/