1

how to get the access token from facebook ios sdk 3.1?

I'm already getting the facebook login. Once the login is completed, the app comes to foreground. Although I could not yet figure out how to get the access token from this.

I get null from [[FBSession activeSession] accessToken]; command.

Any ideas?

Maduranga E
  • 1,679
  • 5
  • 23
  • 37
  • I think this you are facing similar error like http://stackoverflow.com/questions/12745235/handle-invalid-accesstoken-with-fbsession-openactivesessionwithreadpermissions-i – Kamleshwar Oct 19 '12 at 08:48

4 Answers4

6

accessToken is deprecated so you should use this ...

[[FBSession activeSession] accessTokenData];

This will help you......

Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76
3

FBSession.accessToken, an NSString*, is deprecated. FB documentation suggests using (FBAccessTokenData*) accessTokenData instead. FBAccessTokenData has a field, (NSString*) accessToken, so the solution is to substitute

[FBSession activeSession].accessToken

with

[FBSession activeSession].accessTokenData.accessToken

EDIT: We're up to SDK 3.8 at the time of this writing.

Olie
  • 24,597
  • 18
  • 99
  • 131
1

Hello try this one works perfectly for me,

[[[FBSession activeSession] accessTokenData] accessToken];

Hope it will help you.

Viktor Petrovski
  • 796
  • 5
  • 14
0

This worked for me. Try this:

[session accessTokenData].accessToken
Ali Shahid
  • 516
  • 1
  • 5
  • 21