I am using the latest version of FBSDKv4.0.1 in my app but only I can sign in to the app. When somebody else is trying to sign in error is obtained, why?
if ([FBSDKAccessToken currentAccessToken])
{
// User is logged in, do work such as go to next view controller.
self.loginButton.readPermissions = @[@"public_profile", @"email", @"user_friends"];
ProgressHUD *HUD=[[ProgressHUD alloc]init];
[HUD showTextOnlyAndHideForChat:@"Fetching details" parentView:self.view];
}
FBSDKLoginManager *login = [[FBSDKLoginManager alloc] init];
[login logInWithReadPermissions:@[@"email"] handler:^(FBSDKLoginManagerLoginResult *result, NSError *error) {
if (error)
{
// Process error
NSLog(@"fbsdk error log");
ProgressHUD *HUD=[[ProgressHUD alloc]init];
[HUD showTextOnlyAndHide:@"Invalid credentials" parentView:self.view];
}
else if (result.isCancelled)
{
// Handle cancellations
NSLog(@"fbsdk Handle cancellations");
ProgressHUD *HUD=[[ProgressHUD alloc]init];
[HUD showTextOnlyAndHide:@"Activity cancelled by user" parentView:self.view];
}
else
{
// If you ask for multiple permissions at once, you
// should check if specific permissions missing
if ([result.grantedPermissions containsObject:@"email"])
{
[[NSUserDefaults standardUserDefaults] setObject:[[FBSDKAccessToken currentAccessToken] tokenString] forKey:@"fbaccesstoken"];
NSLog(@"fbaccesstoken %@",[[FBSDKAccessToken currentAccessToken] tokenString]);
// NSDictionary *dictionaryJSON = [NSJSONSerialization JSONObjectWithData:result options:NSJSONReadingMutableLeaves error:&error];
//NSLog(@"DICTIONARY==%@\nresult===%@",dictionaryJSON,result);
NSLog(@"fbsdk if log");
// Do work
ProgressHUD *HUD=[[ProgressHUD alloc]init];
[HUD hideHudProgress];
//------------test
if ([FBSDKAccessToken currentAccessToken]) {
// ProgressHUD *HUD=[[ProgressHUD alloc]init];
// [HUD showHudProgressWithText:@"Fetching user information.." withView:self.view];
[[[FBSDKGraphRequest alloc] initWithGraphPath:@"me" parameters:nil]
startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) {
if (!error) {
#success statements#
}
This is the error log I am getting.
Error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: unauthorized (401)" UserInfo=0x7ac62bd0 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x79678040> { URL: http://ift.tt/1EbKJQy? token=(access-token-value) { status code: 401, headers {
Allow = GET;
Connection = "Keep-Alive";
"Content-Language" = en;
"Content-Type" = "application/json";
Date = "Sat, 25 Apr 2015 08:09:45 GMT";
"Keep-Alive" = "timeout=5, max=100";
Server = Apache;
"Transfer-Encoding" = Identity;
Vary = "Accept,Accept-Language,Cookie";
"Www-Authenticate" = Token;
} }, NSErrorFailingURLKey=http://ift.tt/1EbKJQy?
NSLocalizedDescription=Request failed: unauthorized (401), com.alamofire.serialization.response.error.data=<7b226465 7461696c 223a2022 41757468 656e7469 63617469 6f6e2063 72656465 6e746961 6c732077 65726520 6e6f7420 70726f76 69646564 2e227d>}
Can anybody please tell me if i made a mistake in this code snippet? Or is it the bug in the latest FBSDK?
Aucun commentaire:
Enregistrer un commentaire