Since the introduction of Graph v2.0, apps are now granted app scoped ids instead of users' real profile ids. What this means is that if I run FB.getLoginStatus, the user id of the logged in user is now the app scoped id rather than the main one.
However, what if I want to work out if a user is an admin of my app? I need to use an app token, and query app/roles. However, the id returned here in the admins section is the actual profile id of the user, not the app scoped id.
My question is - is it even possible to work out if a user is an admin of an app anymore?
Related
Using Facebook API for FB Login, how is possible to know if the user who authorized my application is the application's admin (owner)?
The old days FB return the real FB user id, so it was easy to compare it. Now it returns a number which is not the real FB profile id.
Thank you
The old days FB return the real FB user id, so it was easy to compare it. Now it returns a number which is not the real FB profile id.
That’s called app-scoped user id.
You will have to use that one to identify users within your app. So you need to get your admin user’s app-scoped id once after logging in as that user, and store it somewhere for future comparison.
There is also the /{app-id}/roles endpoint, which you can use to query which users have which role in your app. But that uses app-scoped user ids as well.
If you have multiple apps connected to a business, you can also use the User Ids For Apps endpoint to be able to match app-scoped user ids across different apps. (You will still have to use the app-scoped id for one of your “main” apps to compare against though; the global user id is not available at all any more via API / to 3rd-party apps.)
We are trying to update Facebook login for a device and found out different uid generated while login via PC browser and device login method. The uid generated by browser can get user feeds, but it return empty for uid generated by device login. Does anyone know why there is different uid for same user?
It's by design so that unrelated apps can't correlate their users.
Straight from the upgrade docs, emphasis mine;
App-scoped User IDs
Facebook will begin to issue app-scoped user IDs when people first log into an instance of your app coded against v2.0 of the API. With app-scoped IDs, the ID for the same user will be different between apps.
No matter what version they originally used to sign up for your app, the ID will remain the same for people who have already logged into your app. This change is backwards-compatible for anyone who has logged into your app at any point in the past.
If you're not mapping IDs across apps, then no code changes should be required. If you need to map the same user IDs across multiple apps or run cross-app promotions, we've added a new API called the Business Mapping API. This lets you map a logged-in user's IDs across apps as long as those apps are all owned by the same business.
We had fetched friend's data prior april changes of facebook, where me/friends returned the actual user ids of all of my friends. Even today if I query for my id it would return me the actual user id and not the app scoped id as I was previously connected to the app.
My question is if my friend connects this app today. Will he be getting the new app scoped id or the actual fb user id as previously received in my friendlist?
Whether you get an app scoped user id, or the global one, depends on when the user logged in to your app for the first time. If that was after API v2 was introduced, then you get their app-scoped user id.
You can not figure out if a new user that logs in to your app for the first time now (and will get an app-scoped user id) is identical to a user whose global id you got long time ago by reading someone’s friend list.
Your app will only be able to “see” friends of the current user now, if they are users of the app as well, and have granted user_friends permission as well.
I want to see who is going to a Facebook event, so I use the API to get the attendees. The users I get have an app scoped user id.
But here is the thing: sometimes the same user gets a different App Scoped User Id. So for example, the user John Doe first has an app scoped user id of 1000000, and a week later it is 2000000.
I get redirected to the same John Doe profile when I visit these urls:
facebook.com/app_scoped_user_id/1000000
facebook.com/app_scoped_user_id/2000000
Are these app scoped user ids temporary ids?
Edit:
This is the API call I use to get the event attendees:
https://graph.facebook.com/v2.3/EVENT_ID_HERE/attending?access_token=app_id|app_secret
App Scoped IDs are definitely not temporary if the user authorized your App. If the same user gets a different App Scoped ID, then i assume it´s because he is did NOT authorize your App. It makes sense, because non-authorized users should not be stored. If you think that this is a bug, you should file a report here: https://developers.facebook.com/bugs/
Facebook's graph api now returns user ids that are scoped to the app, but my concern is that they will change if the user unauthorizes the app and then reauthorizes.
Is this the case? Or does the scoped id persist between authorizations / installs?
A user that authorized your app will always have the id that you got when they authorized the first time. Doesn't matter what they do after that.