Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9234063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:42:06+00:00 2026-06-18T06:42:06+00:00

Is there a way to fetch cached access token through FBSession using Facebook SDK

  • 0

Is there a way to fetch cached access token through FBSession using Facebook SDK if the user is logged in native Facebook.

I am trying to implement autologin through Facebook in an app i.e.when a user is logged in native Facebook then the app should not ask for the login and user should get automatically logged in.

I have used FBSession and FBTokenCacheStrategy and the user is getting logged in automatically but I am not able to fetch the access token which I need to call some API. The following code I am using to get this done :

CacheToken = [[FBTokenCache alloc]init];
NSArray *permissions = [[NSArray alloc]initWithObjects:@"email,user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins", nil];


self.fbsession = [[FBSession alloc] initWithAppID:@"484473011575776"
                                              permissions:permissions
                                          urlSchemeSuffix:nil
                                       tokenCacheStrategy:CacheToken];

(fbsession is the object of Facebook SDK class FBSession)
[FBSession setActiveSession:self.fbsession];


[FBSession openActiveSessionWithReadPermissions:permissions
                                                   allowLoginUI:YES
                                              completionHandler:^(FBSession *session, FBSessionState state, NSError *error) {
                                                  [self sessionStateChanged:session state:state error:error];

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T06:42:07+00:00Added an answer on June 18, 2026 at 6:42 am

    To get the access token you should use this:
    [FBSession activeSession] accessToken]

    However, it seems like you want to check whether there is already a (cached) access token. To do this you can do this:

    // See if we have a valid token for the current state.
    if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
        NSLog(@"The value access token is: %@", [[FBSession activeSession] accessToken]);
    } else { 
        // No, display the login page.
    }
    

    Make sure also to do this in your app delegate or the access token will be nil:

    - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
    {
        return [FBSession.activeSession handleOpenURL:url];
    }
    
    - (void)applicationDidBecomeActive:(UIApplication *)application
    {
    // We need to properly handle activation of the application with regards to Facebook Login
        // (e.g., returning from iOS 6.0 Login Dialog or from fast app switching).
        [FBSession.activeSession handleDidBecomeActive];
    }
    

    Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way we can fetch X509 Public Cetrificates using c# from AD
Is there a way to fetch the current reference count for an NSObject (i.e.
Is there way that I can read the file from remote server using fopen
So yeah, I'm just trying to see if there is a more elegant way
We are using APC as an opcode cache. Is there a way to get
Using ServiceStack, is there a way to perform multiple read commands (in particular the
Is there way to get file from windows xp command prompt? I tried to
Is there way to automatically maximize the output window on hitting build and then
Is there way to copy a file into Plone with WebDAV and have Plone
is there way how to get name ov event from Lambda expression like with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.