Facebook 身份验证错误 - 操作无法完成

发布于 2025-01-07 14:58:42 字数 1165 浏览 0 评论 0原文

我的游戏中有一个选项,可供用户将成就发布到他们的墙上。如果他们已登录,即他们的令牌仍然有效,那么它就可以正常工作。但是,如果他们需要更新令牌,应用程序将退出,Facebook 身份验证页面会加载一秒钟,然后返回应用程序(如果他们主动注销,则只需在身份验证页面上单击“确定”,否则会自动发生) 。

问题是,如果发生这种情况,当游戏返回时,请求会失败。但由于他们现在已经登录,如果他们再次按下“分享到墙上”按钮,效果就很好。失败的请求输出的错误消息:

    DIDLOGIN
2012-02-21 12:01:33.502[18153:15803] Response received
2012-02-21 12:01:33.502[18153:15803] Request did load raw response
2012-02-21 12:01:33.502[18153:15803] Request failed, error: Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x9992010 {error=<CFBasicHash 0x99785e0 [0x2093b38]>{type = mutable dict, count = 3,
entries =>
    2 : <CFString 0x9963370 [0x2093b38]>{contents = "type"} = <CFString 0x99952a0 [0x2093b38]>{contents = "OAuthException"}
    3 : <CFString 0x99631e0 [0x2093b38]>{contents = "message"} = <CFString 0x997e5b0 [0x2093b38]>{contents = "An active access token must be used to query information about the current user."}
    6 : <CFString 0x998c370 [0x2093b38]>{contents = "code"} = 2500
}
}

我不确定为什么在我刚刚成功授权时会收到 OAuthException?

感谢您的帮助!

I have an option in my game for users to post an achievement to their wall. If they are logged in, i.e. their token is still active, it works fine. However, if they need to renew their token, the app exits and the Facebook authentication page loads for a second before returning to the app (they only need to click OK on the authentication page if they have actively logged out, otherwise it happens automatically).

The problem is that if this happens, when the game returns, the request fails. But since they're now logged in, if they were to press the 'share to wall' button a second time, it works fine. The error message output by the failed request it:

    DIDLOGIN
2012-02-21 12:01:33.502[18153:15803] Response received
2012-02-21 12:01:33.502[18153:15803] Request did load raw response
2012-02-21 12:01:33.502[18153:15803] Request failed, error: Error Domain=facebookErrDomain Code=10000 "The operation couldn’t be completed. (facebookErrDomain error 10000.)" UserInfo=0x9992010 {error=<CFBasicHash 0x99785e0 [0x2093b38]>{type = mutable dict, count = 3,
entries =>
    2 : <CFString 0x9963370 [0x2093b38]>{contents = "type"} = <CFString 0x99952a0 [0x2093b38]>{contents = "OAuthException"}
    3 : <CFString 0x99631e0 [0x2093b38]>{contents = "message"} = <CFString 0x997e5b0 [0x2093b38]>{contents = "An active access token must be used to query information about the current user."}
    6 : <CFString 0x998c370 [0x2093b38]>{contents = "code"} = 2500
}
}

I'm not sure why I'm getting an OAuthException when I've just successfully authorised it?

Thanks for any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不知所踪 2025-01-14 14:58:42

当您设置参数字典并将其发送到 facebook 时..也传递访问令牌,就像这样

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"someText",  
                               @"message",
                               [fb accessToken], 
                               @"access_token",nil];

when you set the dictionary of params that you send it to the facebook .. pass the acces token also ,, like this

    NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               @"someText",  
                               @"message",
                               [fb accessToken], 
                               @"access_token",nil];
乱了心跳 2025-01-14 14:58:42

嗯,我发现了问题。至少我认为我找到了它,因为它现在可以工作了,我只是希望我没有在这个过程中引入另一个错误。基本上我的登录编码如下:

    - (void)postAchievement:(NSString *)message withPicture:(NSString *)pictureURL {
    //Set post to TRUE so the delegate posts when the method returns and configure the message. 
    DLog(@"Achievement message: %@", message);
    self.postAchievement = TRUE;
    self.achievementMessage = message;
    self.wallPostPicURL = pictureURL;
    [self fbLogin];
[facebook requestWithGraphPath:@"me" andDelegate:self];
}

    // Save the user's credentials and expiration date
- (void)fbDidLogin {
    DLog(@"DIDLOGIN");
    self.isLoggedIn = TRUE;
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];
}

fbDidLogin 是用户登录时调用的委托方法。 [facebook requestWithGraphPath:@"me" andDelegate:self]; 行是问题所在。我将其移至 fbDidLogin 方法的末尾,现在它似乎工作正常。

Well, I found the problem. At least I think I found it, as it now works, I just hope I didn't introduce another error in the process. Basically my login coded looked like this:

    - (void)postAchievement:(NSString *)message withPicture:(NSString *)pictureURL {
    //Set post to TRUE so the delegate posts when the method returns and configure the message. 
    DLog(@"Achievement message: %@", message);
    self.postAchievement = TRUE;
    self.achievementMessage = message;
    self.wallPostPicURL = pictureURL;
    [self fbLogin];
[facebook requestWithGraphPath:@"me" andDelegate:self];
}

    // Save the user's credentials and expiration date
- (void)fbDidLogin {
    DLog(@"DIDLOGIN");
    self.isLoggedIn = TRUE;
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];
}

fbDidLogin is a delegate method called when the user has logged in. The line [facebook requestWithGraphPath:@"me" andDelegate:self]; was the problem. I moved it to the end of the fbDidLogin method and now it seems to work perfectly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文