我知道这个问题已经被问过了,但是我已经一整天都在阅读帖子,我已经应用了我能找到的所有修复程序,但仍然有问题。
我正在尝试实现Facebook SDK的新单点登录功能,以允许我的应用程序使用Facebook的应用程序而不是webView进行身份验证。当我的应用程序切换到Facebook的应用程序时,它显示正在加载几秒钟,然后切换回来,但令牌仍然为空。我有一种感觉,这与我的应用程序的URL方案有关,但我遵循了许多教程,并且相当有信心,我目前的plist值是正确的:

下面是我在appDelegate和viewController文件中实现的代码: appDelegate.h
Facebook *facebook;appDelegate.m
// Pre 4.2 support
- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
return [facebook handleOpenURL:url];
}
// For 4.2+ support
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
return [facebook handleOpenURL:url];
}SecondViewController.m
-(IBAction) fbButton {
//FACEBOOK INTEGRATION
appDelegate.facebook = [[Facebook alloc] initWithAppId:@"222087841143437" andDelegate:appDelegate];
// Check and retrieve authorization information
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
appDelegate.facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
appDelegate.facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![appDelegate.facebook isSessionValid]) {
appDelegate.facebook.sessionDelegate = self;
[appDelegate.facebook authorize:permissions];
NSLog(@"Token: %@", [defaults objectForKey:@"FBAccessTokenKey"]);
} else {
NSLog(@"Already logged in!");
}
[appDelegate.facebook requestWithGraphPath:@"me" andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result {
NSString *nameID = [[NSString alloc] initWithFormat:@"%@ (%@)", [result objectForKey:@"name"], [result objectForKey:@"id"]];
NSMutableArray *userData = [[NSMutableArray alloc] initWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
[result objectForKey:@"id"], @"id",
nameID, @"name",
[result objectForKey:@"picture"], @"details",
nil], nil];
[userData release];
[nameID release];
NSLog(@"DATA RECEIVED: %@", result);
}
- (void)request:(FBRequest *)request didReceiveResponse:(NSURLResponse *)response {
NSLog(@"request:didReceiveResponse:");
}
- (void)request:(FBRequest *)request didFailWithError:(NSError *)error {
NSLog(@"%@", [error localizedDescription]);
NSLog(@"Err details: %@", [error description]);
};
- (void)fbDidLogin {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[[appDelegate facebook] accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[[appDelegate facebook] expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
NSLog(@"Facebook Logged in!");
[appDelegate.facebook requestWithGraphPath:@"me" andDelegate:self];
}我知道我两次调用appDelegate.facebook的requestWithGraphPath:@"me“和andDelegate:self,但我不认为这是问题所在。
当我按下登录按钮时,下面是控制台中的一段代码:
2011-10-18 15:37:33.287 Track[2235:707] Token: (null)
2011-10-18 15:37:36.578 Track[2235:707] request:didReceiveResponse:
2011-10-18 15:37:36.584 Track[2235:707] The operation couldn’t be completed. (facebookErrDomain error 10000.)
2011-10-18 15:37:36.586 Track[2235:707] Err details: Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x1ce480 {error=<CFBasicHash 0x1c9560 [0x3e368630]>{type = mutable dict, count = 2,
entries =>
2 : <CFString 0x19a830 [0x3e368630]>{contents = "type"} = <CFString 0x11d230 [0x3e368630]>{contents = "OAuthException"}
3 : <CFString 0x1f5b60 [0x3e368630]>{contents = "message"} = <CFString 0x1f8a70 [0x3e368630]>{contents = "An active access token must be used to query information about the current user."}我很感谢你的帮助,我真的希望我不会错过这里解决这个问题的讨论。下面是我通读过但没有成功找到解决方案的几个
How to implement Single Sign On (SSO) using facebook ios sdk for iphone Facebook SSO and request iOS SDK Facebook API for iPhone Error: An active access token must be used
发布于 2011-10-19 04:21:15
确保您的Facebook应用程序(您在Facebook上创建的实际应用程序)未处于沙箱模式,如果处于沙箱模式,请确保您的Facebook应用程序( iPhone Facebook客户端)当前登录的用户是该应用程序的开发人员。
https://stackoverflow.com/questions/7812812
复制相似问题