Take the 2-minute tour ×

When authenticating with following authorization method i'm getting com.facebook.sdk error 5 with startWithGraphPath and startForMeWithCompletionHandler but not with requestWithGraphPath. I'm succesfully getting token (printing in didLogin) and getting anything which i want with requestwithGraphPath but i'm unable to get work with other methods. If anybody encountered with same issue or something similar or has any idea, i'd be happy if you share it.



NSArray *permissions = [[NSArray alloc] initWithObjects: @"user_likes",@"offline_access",@"read_stream",@"publish_stream",nil];
[_facebook authorize:permissions];
share|improve this question
add comment

2 Answers

The startWithGraphPath and other start* methods are likely not picking up an active session. Those methods are relying on an active session being set. See:


"The request uses the active session represented by [FBSession activeSession]."

So you'll have to do something like this:

[FBSession setActiveSession:session];

Where session is an FBSession that you had previously set up.

share|improve this answer
So, i need to create my own session within my session delegate. How i can set up a new session object just with a token which result of authorize method ? –  Atahan Bozkurt Nov 23 '12 at 9:09
I figured out how to do that. Thanks anyway by lighten me up. –  Atahan Bozkurt Nov 23 '12 at 12:48
add comment
up vote 1 down vote accepted

Following solution worked for me. But if you're storing a permanent access token, you need to be sure user not removed application permissions otherwise it will give an error. And you can check that with requestWithGraphPath -> "me/permissions".

Application Init Function (e.g.:didFinishLaunchingWithOptions/or where you init your Facebook object which needs to be fbsessiondelegate in the mean time)

NSArray* permissions = [[NSArray alloc] initWithObjects:@"user_likes",@"offline_access", nil];

        FBSession*oursession = [[FBSession alloc] initWithPermissions:permissions];

FBDidLogin function:

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults synchronize];

Example graph api request function:

NSUserDefaults *userDefaults =[NSUserDefaults standardUserDefaults];
        NSString *key = [userDefaults stringForKey:@"FBAccessTokenKey"];

    FBRequest* ourcon = [[FBRequest alloc] initWithSession:oursession graphPath:@"me/likes" parameters:params HTTPMethod:@"GET"];

            [ourcon startWithCompletionHandler: ^(FBRequestConnection *connection, id<FBGraphUser> result, NSError *error){

                NSArray* collection = (NSArray*)[result data];
                NSLog(@"You have %d like", [collection count]);

                NSDictionary* name = [collection objectAtIndex:14];
                NSLog(@"Like Name: %@", [name objectForKey:@"name"]);
share|improve this answer
add comment

Your Answer


