Figure out which pages I got permissions for from the Facebook Login popup - facebook

I'm building a Chatbot and im trying to connect it with the client Facebook Fanpage programmatically, so I can you receive and send messages on the user behalf on the Fanpage.
So far all is good, I got the Facebook login to work, requesting access to the right permissions, and getting the user short and long lived access token.
However, I'm not sure this access token is valid for which Fanpages, The Facebook login lists all the user Fanpages and he can select which he will give the permission to per the screenshot, but nothing is returned in the payload saying which pages he selected, only the access token as below:
"authResponse": {
"accessToken": "EAAJ911mLyc4BAPsNTMCfVqcf5JkvnGsaZCxXZAZA6slQuubSaZANMB3jsUBZB5ds7opfAuV1ZBB5Vz3NZBLwiN3QO1C5NupvGAbIdzxz91JYWHZCJfwOgawzOswgxAevLDmd6yjRQ4LASROcbnyTtHcnBeE08qvWSYJ6sJrzZCptZB94NZA1tz6tVKOIZCIgrhdaM1IB4feF2LCaF86eIXH1yAZCE",
"userID": "2917511921114302",
"expiresIn": 5498,
"signedRequest": "YpjihSoIBgcl2fUxkVBE2b7_mtXD7RK7ZT7sn77uqRY.eyJ1c2VyX2lkIjoiMjkxNzUxODkyMTcxNDMwMiIsImNvZGUiOiJBUUFhNGVZRlJTUnIyNDkwT252dFdEYTlfTnh3cm1QWnNoTUF4bzNUYzdERS00MmZXT0pvTEY4XzUybUJ6VmhzeF81eG05VjFNZV33daVhvM3lQV1FscTE1czZoM25uYUpnTzdObGpxUkJhQTNpRnhtMTA1TFMtbVRPa0dTNGNiNEFpbXN3dTcxcEZiX0hjZG1MVXFldmo5QkVQMXJzYnRkYkw5LWNzSXZlWWIyWmZQR25TNW93aUdCTjRIZmRqdjRSbm9aMkllRDRPN3R1RUtfbmhDMG55cDd1UDZGR1JCOVFaV3ZQQUVEQTNwN2dJX0x3X1ZDYUsteG00Tk9BbkJhZEdnVS16eXJNR3J1S0owZWFLUFF6YkFkNWJRaUJzNmw1a2xvUl9IOFhieFpiMjlaUmJHTjBOUjJoZmk4bHNISU5yMW91SjUyXzJqWTNaTy1xZ3FSX1RObSIsImFsZ29yaXRobSI6IkhNQUMtU0hBMjU2IiwiaXNzdWVkX2F0IjoxNjc1OTUyOTAyfQ",
"graphDomain": "facebook",
"data_access_expiration_time": 1683728902
},
"status": "connected"
}
And screenshots for the page selection from the Facebook login:
How can I can get the pages id selected, so I can request later the page access token for those specific pages? Thanks.

Related

Post on Facebook Page Using FB Graph API using FB Live but un-reviewed App

I want to post on my own Facebook Page using Graph API.
For this, I have created an App.
When App is in Dev Mode, I am able to post on page using Page Access Token with proper permissions.
However, the problem here is, the post are not visible to public unless I make the App Live. The posts are only visible to Page Admins.
But as I make my App Live, I am getting below exception from FB APIs.
{
"error": {
"message": "(#200) If posting to a group, requires app being installed in the group, and \\\n either publish_to_groups permission with user token, or both pages_read_engagement \\\n and pages_manage_posts permission with page token; If posting to a page, \\\n requires both pages_read_engagement and pages_manage_posts as an admin with \\\n sufficient administrative permission",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "abcdefgh"
}
}
I regenerated the Page Access token after I make my App Live but still above error is coming.
I checked some resources which says that I need to submit my App for review. But I don't want to go through that lengthy process.
So, Is there any otherway with which I can post on facebook page using API without putting my App for review process ? Will any other kind of token (i.e. other than page access token) work here ?
Please note, I want to make sure the posts I make to be visible by everyone and not just page admins.

Graph API doesn't return Page Events with a valid Page Access Token

Due to many Facebook's access policies changes, the question may seem duplicated, but it's not.
My application followed all facebook approval process, and at the moment it has been approved by the "App Review" to get "manage_pages" permission. This allows to obtain a "Page Access Token" which grants the access to the page events, wherever the user is Guest or Host. (Facebook manage_pages)
After switching from Development to Live mode, the /page/events endpoint returns an empty object, with all my granted users, with a valid longlive page access token.
{
"data": [
]
}
Has anyone ever encountered this issue?
Thanks.
Past references about this:
Facebook Graph API does not return Page Events
How can I get the events for a Facebook page?

Facebook App Admin cannot post Live Video API request on its own page

I'm using the Facebook Live Video API for testing purpose.
I've created a Test User, associated with my Facebook App, with the following permissions: publish_actions, user_videos, publish_pages, manage_pages
Using graph API explorer, I can make a POST request on /{user_id}/live_videos, using the Test User ID and Access Token (got it from the My App -> Role -> Test Users).
But, if I create a page with the Test User (logged in with its email), POST resquest on /{page_id}/live_videos, with the test user page ID and Page Access Token with required permissions, I get an error:
"message": "(#100) No permission to perform current operation.",
"type": "OAuthException",
"code": 100,
I have the exact same issue when I'm not using a Test User, i.e. when I try to post live videos on a page id with an admin page token, while it works on its user id with user access token.
I've followed these documentation:
Live Video API
Why can't I POST live_videos on page ID with a page access token while it works on user ID with user access token?
Best regards.
Nico
POSTing a live_video with the page access token should work now. After chatting with the engineers at FB, they fixed the problem, so it wasn't an issue with just you.

Facebook: App Access token, Posting to a User

I went through this wonderfull tutorial on Using App Access token. According to this post it says that:
If the user has not provided the appropriate permissions to publish on the user’s behalf, you will receive an error message. For example, if the user has not provided the publish_stream permission, the following error will be returned:
{
"error": {
"message": "(#200) The user has not granted the application the permission to automatically publish feed stories",
"type": "OAuthException",
"code": 200
}
}
Now is there any other way to post to a users wall who has not authorized the app?
My query is this:
I have two logins for my app, one Login with Email and other FB Connection. So a user may login with email or facebook to my app. If he logs in with facebook there is no problem at all as i have his access token. If he login with email , then i don't have his user access token, so in this case i want to use the App Access token to fetch the users friends and then allow him to post to friends wall [friends who are not a member of our app / not authorized our app].
there is no way to post to a user wall who has not authorized the app.
one possible soln:
you have to link up the user login via the email and fbID
stored the access token when the user accesses your app via fbID
if the user login via the email, then get the access token from local storage and use it for the posting.

Post on page with impersonate access_token?

I have a question, I'm trying to post on a page with the token acquired from
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&
grant_type=client_credentials
I guess the app has permission to post on that page, but when I try to post I get the following error
{
"error": {
"message": "(#200) The user hasn't authorized the application to perform this action",
"type": "OAuthException"
}
}
How do I verify the permission?
Basically, I want to be able to post to a page as a page without asking user to login, Would be great if someone can help me out!
The token that you are acquiring is an App Access Token.
And to post on a page as a page itself, you need a page access token.
To get the page access token, you need to make the following API call with an access token with manage_pages permission:
/{page-id}?fields=access_token
this will give you the page access token for your pages. Use that and publish the post.
You can also have a never-expiring page access token. To get one follow this: What are the Steps to getting a Long Lasting Token For Posting To a Facebook Fan Page from a Server