Any way to pull out session key from access token returned by Facebook iOS SDK?

后端 未结 2 751
刺人心
刺人心 2021-01-03 12:58

I need Facebook session key to be used in this senario: http://developers.facebook.com/docs/chat/#platauth

However, the current Facebook iOS SDK returned us a access

相关标签:
2条回答
  • 2021-01-03 13:14

    Current FB access token has following format ('|' is a delimiter): || For example, for a access_token like this: 146012674543599|de29194522ad43g16ec2ca9b-612345672|kK5HvfSTbJx-x21rMsTyttifij0 Session Key is : de29194522ad43g16ec2ca9b-612345672

    Cheers

    0 讨论(0)
  • 2021-01-03 13:29

    I still dont have the formula to convert FBAppAuth-ed or SafariAuth-ed access_token fragments to session_id. However, the following description will help in getting an access_token in described formula which can then be easily fragmented to derive session_id. Hope this helps.

    In iOS SDK Version 2, login is handled by following API in Facebook class:

    - (void)authorize:(NSArray *)permissions delegate:(id<FBSessionDelegate>)delegate;
    


    In the implementation of same API, if we turn off the FBAppAuth and SafariAuth, then it will invoke login dialog box and the returned access_token will be of format APP_ID | SESSION_KEY | DIGEST

    - (void)authorize:(NSArray *)permissions delegate:(id<FBSessionDelegate>)delegate 
    {
      [_permissions release];
      _permissions = [permissions retain];
      _sessionDelegate = delegate;
        //[self authorizeWithFBAppAuth:YES safariAuth:YES];
      [self authorizeWithFBAppAuth:NO safariAuth:NO]; // Turned off FBApp and Safari auth
    }
    


    The returned access_token can be captured in following call back method in Facebook class (please put a NSLog to print the token) :

    - (void)fbDialogLogin:(NSString *)token expirationDate:(NSDate *)expirationDate 
    


    0 讨论(0)
提交回复
热议问题