iOS FB SDK访问令牌是零
我使用的是fbsdkcorekit和fbsdkloginkit v13.1
我的应用程序中有一个fb登录按钮,其中包含以下处理程序:
- (void) loginButton:(FBSDKLoginButton *)loginButton
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
error:(NSError *)error{
if (error || (result && result.isCancelled)) {
return;
}
[self loginWithFB];
}
该代码的此部分正常工作,按钮状态也更改为log
成功后>登录,但是当我想提出图形请求时,它们会失败,因为它没有fb访问令牌([fbsdkaccesstoken currentAccessToken]是nil
)
- (void) loginWithFB {
NSString *fbAccessToken = [[FBSDKAccessToken currentAccessToken] tokenString];
[[[FBSDKGraphRequest alloc]
initWithGraphPath:@"me"
parameters:@{@"fields": @"id"}
tokenString:fbAccessToken
version:nil
HTTPMethod:@"GET"
]
startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
if (!error) {
...
} else {
...
}
}];
}
我不确定是什么原因导致了这一点,boottrap(appdelegate) ,正确设置FB SDK的设置(检查了比我想要的更多),但是 docs 明确指出,当按钮登录状态时,应提供CurrentAccessToken。 (fbsdkloginmanager直接与[FBSDKACCESSTOKEN CurrentAccessToken]合作,并在成功的授权下设置“ CurrentAccessToken”(或在logout中设置零)。
)。)
I'm using FBSDKCoreKit and FBSDKLoginKit v13.1
I have a FB Login Button in my application with the following handler:
- (void) loginButton:(FBSDKLoginButton *)loginButton
didCompleteWithResult:(FBSDKLoginManagerLoginResult *)result
error:(NSError *)error{
if (error || (result && result.isCancelled)) {
return;
}
[self loginWithFB];
}
This part of the code works fine, the buttons state also changes to Log out
after a successful login, however when I want to make graph requests they fail because it doesn't have a FB Access token ([FBSDKAccessToken currentAccessToken] is nil
)
- (void) loginWithFB {
NSString *fbAccessToken = [[FBSDKAccessToken currentAccessToken] tokenString];
[[[FBSDKGraphRequest alloc]
initWithGraphPath:@"me"
parameters:@{@"fields": @"id"}
tokenString:fbAccessToken
version:nil
HTTPMethod:@"GET"
]
startWithCompletion:^(id<FBSDKGraphRequestConnecting> connection, id result, NSError *error) {
if (!error) {
...
} else {
...
}
}];
}
I am not sure what is causing this, the bootstrap (AppDelegate, plist, etc.) setup for the FB SDK is set up correctly (checked this more than I would like), but the docs clearly state that when the button has a logged in state, the currentAccessToken should be available.
(FBSDKLoginManager works directly with [FBSDKAccessToken currentAccessToken] and sets the "currentAccessToken" upon successful authorizations (or sets nil in case of logOut).
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论