I have a portal which has the following functionality to comment on FaceBook posts:
1. When a user chooses to a comment on a post, FB credentials of that specific user are requested.
2. When that user signs in with FB credentials my FB app asks for public profile permission.
3.When I use the access token of the same app in the graph explorer it does not return me the age_range of the users (irrespective of whether they are logged in or logged out of FB) who have approved/not approved my app.
4. I have checked for the public_profile permission even on the access token as well, using the debug feature in graph explorer but still I'm not getting the age_range.
Can anyone tell me step by step procedure to get the age_range of a user?
Related
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.
I have a React application where I'm able to link accounts from different social medias to the main username and password account. I linked my Facebook account where I manage several other page and I assumed that with the user_id and access_token that comes back from Auth0 I'd be able to access my pages but I haven't been able to do that. Does my Auth0 app need to be reviewed by Facebook before I get access ?
When I go to the Graph API Explorer, paste in the access_token from Auth0 and try to access ${user_id}/accounts, I get the following Debug message:
The field 'accounts' is only accessible on the User object after the user grants either the 'pages_show_list' or 'manage_pages' permission.
even tho I clearly granted those permission on Auth0->Connections->Social.
What am I missing here ?
Any push in the right direction would be greatly appreciated.
I am not able to post Facebook using the custom-ui project of socialauth-android.
Here is the error log.
10-31 13:18:05.124: D/SocialAuthError(21880): org.brickred.socialauth.exception.SocialAuthException: org.brickred.socialauth.exception.SocialAuthException: Status not updated. Return Status code :403
10-31 13:18:05.124: W/System.err(21880): org.brickred.socialauth.android.SocialAuthError: Message Not Posted
10-31 13:18:05.124: W/System.err(21880): at org.brickred.socialauth.android.SocialAuthAdapter$6.run(SocialAuthAdapter.java:868)
10-31 13:18:05.124: W/System.err(21880): at java.lang.Thread.run(Thread.java:818)
I am not able to find the issue. I am using the same API keys got from the Github source.
You are getting 403 Authentication Error that clearly means that your app is presently not authorized to publish on Facebook profile of the user.
There is some problem the way you are trying to use Facebook APIs. I would suggest you to the latest Facebook SDK for Android as some of the older methods may be deprecated. Let me tell you the approach for doing this right way. (I recently implemented latest Facebook SDK)
You need a permission
There are some specific permissions that you require to do some specific operations with Facebook SDK. For example, You need publish_actions permission if you want your app to post status on user's profile.
Check Out It says,
For example, the publish_actions permission lets you post to a person's Facebook Timeline.
How to get Permissions
You need to show the user a login button which will ask him to do login with his facebook account and notifying the user what your app may do with his Facebook profile. It will show the permissions. In your case you need to add a login button with publish_actions permission. Once the user accepts it, your app becomes authorized to post status.
Complete Tutorial is here for doing the login process of Facebook with permissions.
You will need to do the following,
LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setFragment(this);
authButton.setReadPermissions(Arrays.asList("user_likes", "user_status", "publish_actions"));
return view;
So you can see we are asking the user to give you the publish_actions permission. It is not mandatory to include user_likes or user_status permissions. You can remove them if you don't need them.
Next what after login
After the user logs in, you get an authentication token in your session with Facebook. So now you can use that to publish on user's profile.
How to post
Now there are many ways to publish posts or status on Facebook. The first one I would like to discuss is using the Graph API
Here is somewhat code, you can use to publish to facebook.
Session session = Session.getActiveSession();
new Request(
session,
"/me/feed",
null,
HttpMethod.POST,
new Request.Callback() {
public void onCompleted(Response response) {
}
}
).executeAsync();
NOTE
You do also need to create developer account with facebook and add your app to its dashboard, generate an app_id and mention the same in your AndroidManifest.xml file.
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.
I used the graph api in order to connect the user and publish an event on its wall.
But if I am connected as a page, I get this error message : "You need to be connected as a user and not as a page to run this app"
But I which I could publish my event on a fan page.
Here is my TOKEN_URL
How shoud I do to be able to publish on my fan page.
How can I enable that ?
To publish "on behalf" of a Page, you need to use a Page access token. To get a Page access token, first get an access token for a user with the manage_pages and publish_stream permissions:
https://graph.facebook.com/oauth/authorize?client_id=YOUR_APP_ID&
redirect_uri=YOUR_REDIRECT&scope=manage_pages,publish_stream&type=user_agent
Then, using the access token you get as a result, do a GET of:
https://graph.facebook.com/me/accounts?access_token=ACCESS_TOKEN_FROM_STEP_1
Here, you'll find the list of the Pages the user is an admin of. Here you can grab the access token for one of these Pages. Now calls you make will be made on behalf of the Page. Now anything you try to post will be posted as the Page. If you are trying to create events, you may also need the create_event permission.
To see how this works, you can test this out using these URLs in your browser or in the Graph API Explorer.
You need to get an offline access token with the manage_pages permission for the user that created/owns the fan page. After obtaining the user's access token, then you need to get the page's access token.
See this answer with code for details:
How can I use 'manage_pages' permission with the SDK on Facebook?
You could log in as the administrator of the page and create an offline access token for that user.