10

I see that the access token is available in the Facebook object, but I don't see a Facebook user Id.

I could make a graph request to "me" to get the Facebook Id, but I'd prefer not to make the extra api call.

MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460

4 Answers4

15

There is an easy way to get this these days; assuming you already have a FBSession open, you could just do this:

[FBRequestConnection startForMeWithCompletionHandler:
  ^(FBRequestConnection *connection, id result, NSError *error)
  {
      NSLog(@"facebook result: %@", result);
  }];
Juan
  • 1,428
  • 2
  • 22
  • 30
8

You will have to call /me to get the id. iOS access tokens are now encrypted and thus you won't be able to parse the user id from it. Also, server side tokens will all be encrypted with oauth 2.0 soon too.

bkaid
  • 51,465
  • 22
  • 112
  • 128
0

You can just use this:

[[account valueForKey:@"properties"] valueForKey:@"uid"]

E-mail can be found with this:

[[account valueForKey:@"properties"] valueForKey:@"ACUIDisplayUsername"]

where account is ACAccount type of course

k06a
  • 17,755
  • 10
  • 70
  • 110
0

Can get it with [FBSession activeSession].accessTokenData.userID

Alexandre G
  • 1,655
  • 20
  • 30