0

I'm having an issue with the Facebook graph API, and more precisely the iOS SDK. My code used to work properly but now I get this error description when trying do use it (to get personal feed, friend's feed, friends list,...) :

Err details: Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x7113b80 {error=<CFBasicHash 0x7113910 [0x176e400]>{type = mutable dict, count = 2,
entries =>
    2 : <CFString 0x7121e60 [0x176e400]>{contents = "type"} = <CFString 0x7113a20 [0x176e400]>{contents = "OAuthException"}
    3 : <CFString 0x7113b40 [0x176e400]>{contents = "message"} = <CFString 0x7113a00 [0x176e400]>{contents = "An access token is required to request this resource."}
}
}

Would anyone have an idea of where it might come from ?

Here is my source code too :

facebook = [[Facebook alloc] initWithAppId:@"00000000000000"];
    NSArray *permissions =  [[NSArray arrayWithObjects:@"read_stream", @"publish_stream", @"offline_access",nil] retain];
    [facebook authorize:permissions delegate:self];
    [facebook requestWithGraphPath:@"1342568689/feed" andDelegate:self];
bkaid
  • 51,465
  • 22
  • 112
  • 128
Ben
  • 193
  • 2
  • 13

2 Answers2

0

Also, offline_access is being depricated, they suggest doing a check on app init to extend the token- see documentation, but snippet here:

-(void)fbDidExtendToken:(NSString *)accessToken expiresAt:(NSDate *)expiresAt { NSLog(@"token extended"); [self storeAuthData:accessToken expiresAt:expiresAt]; }

Anna Billstrom
  • 2,482
  • 25
  • 33
0

Well, I've definitely found the Facebook SDK to be a little tricky myself, but here are a couple things I'm seeing that will hopefully help.

First off, I think you might have copied a couple methods incorrectly when entering the code accompanying your question. The allocation of the "facebook" object is where the delegate is set, and the "authorize" method only takes a NSMutableDictionary of parameters. For clarity's sake, the code should look like:

facebook = [[Facebook alloc] initWithAppId:@"00000000000000" andDelegate:self];
NSArray *permissions =  [[NSArray arrayWithObjects:@"read_stream", @"publish_stream", @"offline_access",nil] retain];
[facebook authorize:permissions];
[facebook requestWithGraphPath:@"1342568689/feed" andDelegate:self];

Aside from that, the only real problem is that you are making a call to the graph API before the app has had time to be authorized completely. These calls are all done asynchronously, so as the main thread is moving on to your requestWithGraphPath:andDelegate call before the authorization process has actually returned a valid access token. You could move this call, or any other like it, into button onClick handler, or for a more direct test, into the Facebook Session Delegate method fbDidLogin.

Hope that helps!

GrimmRanger
  • 428
  • 3
  • 9