If you have a Facebook, for instance Zuckerbergs user id '4', or username, 'zuck', how do you get the new app-scoped id with Graph v2.0
using the app's access token? Can't seem to find anything about this in the docs.

- 3,878
- 3
- 40
- 64
-
If you are trying to determine whether an id is app scoped, user ids fall in the range [(id < 2200000000 || (id >= 100000000000000 && id <= 100099999989999)](https://github.com/facebookarchive/facebook-js-sdk/blob/deprecated/src/xfbml/helper.js#L37). App scoped user ids will fall outside of this range – Matthew Kolb Sep 28 '20 at 21:10
3 Answers
This is basically the answer given to the other-way-around question, Get Facebook User ID from app-scoped User ID .
Basically, easiest straight forward flow is a call to https://graph.facebook.com/?ids=http://facebook.com/[FBID/USERNAME]&access_token=[APP_ID]|[APP_SECRET]
Doing that for Zuckerberg, will give you the familiar
{
"http://facebook.com/4":
{
"id": "4",
"first_name": "Mark",
"gender": "male",
"last_name": "Zuckerberg",
"link": "https://www.facebook.com/zuck",
"locale": "en_US",
"name": "Mark Zuckerberg",
"username": "zuck"
}
}
But, if that user had only logged in to your app for the first time after 30th May 2014 (the changeover date), he'd have something like...
{
"http://facebook.com/4":
{
"id": "277123456789101",
"first_name": "Mark",
"gender": "male",
"last_name": "Zuckerberg",
"link": "https://www.facebook.com/zuck",
"locale": "en_US",
"name": "Mark Zuckerberg",
"username": "zuck"
}
}
Giving you the 277... app-scoped id for your app.
-
6Unfortunately, doesn't look like this works for 2.0/2.1 (at least not anymore) – Nate Sep 27 '14 at 16:11
-
I just successfully make this call using version 2.3 of the Facebook Graph API: https://graph.facebook.com/v2.3?access_token=[KEY]%7C[SECRET]&ids=4 – Raymond Yee Apr 17 '15 at 18:36
In addition to the comment by @Raymond Yee, you have to provide APP_ID
, APP_SECRET
and FACEBOOK_USER_ID
(note that this is the numeric id, not the username):
So it works with this URL:
https://graph.facebook.com/v2.3?access_token=[APP_ID]%7C[APP_SECRET]&ids=[FACEBOOK_USER_ID]

- 62,134
- 8
- 100
- 147

- 695
- 5
- 18
-
1You have to put user ID, not username!!! Replace FACEBOOK_USER_ID with the numeric id, not with username – Deyan Vitanov Dec 03 '15 at 23:32
You also get real facebook id from app scoped user id. Solution here https://stackoverflow.com/a/34450491/2181069

- 1
- 1

- 123
- 7