Facebook: App Access token, Posting to a User - facebook

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.

Related

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

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.

Get user profile link from Facebook's Graph API

I have an app-scoped user id (ASUID) for a Facebook user and I wish to obtain a link to that user's profile page.
A post on Facebook's Developer blog dated May 1, 2018 states that this link is accessible as of Graph API v3.0 through the link field on a user object. Access to this field requires the user_link permission be approved for the app and granted by the app user.
I have attempted to access this field with a user access token associated with my test app and I have verified the access token has the user_link permission granted via the Access Token Debugger. However, the link is not included in the response.
Request:
https://graph.facebook.com/v3.0/[ASUID]?fields=link&access_token=[ACCESS_TOKEN_W_USER_LINK_PERMISSION]
Response:
{ "id": "[ASUID]" }
Is there any indication as to why this is not working?
As documented, the user_link permission requires an App Review pass before it's available to live apps.
At time of writing this answer there is no way to get user profile page using Facebook API.

How to post status for user in 'Facebook At Work' using Graph API?

I working on a project related to Facebook At Work. (Fb#W). I have admin access token and community id.
The app need to post statuses on behalf of user in Facebook at work. I tried to add impersonate_token to API call but the result return an error as follow:
"message": "(#200) The user hasn't authorized the application to perform this action"
The problem is user can not authenticate facebook at work account. Anyone know how to do this?
Thank you for reading

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 opengraph login

I have a question about facebook login on my website. What I have now is simple login process which logs in user but each time facebook asks user to grant my app an access permission.
It looks like this:
1) user clicks "login with facebook" and is sent to facebook. He/she gives permission to access his/her account
2) I receive back an authentication token for this user
I'd like to have the following flow:
1) when user clicks "login with facebook" then he would be redirected to facebook website and after he logs in I should receive a facebook user ID,
2) search for user id in local database and if it is found then just use stored token
2a) If user is not found then send him back to facebook to grant my application access permissions
2b) receive user token from facebook and store it in local database
Basically, the difficulty for me is to query facebook for current user id without passing a user token to facebook. Thanks for any help
to query facebook for current user id without passing a user token to facebook
No. This isn't possible, facebook will never give you user_id without their knowledge. They have to authorize your application first.