IOSLinkedInAPI: Authorization failed LinkedIn1: Error Domain=LIALinkedInERROR Code=1 "The operation couldn’t be completed. (LIALinkedInERROR error 1.)"
Hi, I am getting the next error:
Authorization failed LinkedIn1: Error Domain=LIALinkedInERROR Code=1 "The operation couldn’t be completed. (LIALinkedInERROR error 1.)"
when I tap a custom build LinkedIn button.
Here is the code that I am using:
#pragma mark Linkedin integration
- (void)suggestionsPopupLinkedInButtonFunction{
dispatch_async(dispatch_get_main_queue(), ^{
[_client getAuthorizationCode:^(NSString *code) {
[_client getAccessToken:code success:^(NSDictionary *accessTokenData) {
NSString *accessToken = [accessTokenData objectForKey:@"access_token"];
[self requestMeWithToken:accessToken];
} failure:^(NSError *error) {
NSLog(@"Quering accessToken failed %@", error);
}];
}
cancel:^{
NSLog(@"Authorization was cancelled by user");
}
failure:^(NSError *error) {
NSLog(@"Authorization failed LinkedIn1: %@", error);
}];
});
}
- (void)requestMeWithToken:(NSString *)accessToken {
[_client GET:[NSString stringWithFormat:@"https://api.linkedin.com/v1/people/~:(skills)?oauth2_access_token=%@&format=json", accessToken] parameters:nil success:^(AFHTTPRequestOperation *operation, NSDictionary *result) {
NSLog(@"current user %@", result);
//process the received result and convert it to string
NSString *skillFinalString = @"";
for (int countValuesSize = 0; countValuesSize < [[[result objectForKey:@"skills"] objectForKey:@"values"] count]; countValuesSize++) {
NSString *skillValueString = [[NSString alloc] initWithString:[[[[[result objectForKey:@"skills"] objectForKey:@"values"] objectAtIndex:countValuesSize] objectForKey:@"skill"] objectForKey:@"name"]];
NSLog(@"skillValueString = %@", skillValueString);
if (countValuesSize < [[[result objectForKey:@"skills"] objectForKey:@"values"] count] - 1) {
skillFinalString = [NSString stringWithFormat:@"%@; ",[skillFinalString stringByAppendingString:skillValueString]];
} else {
skillFinalString = [skillFinalString stringByAppendingString:skillValueString];
}
}
//send the skillFinalString data to class variable and send them to server when finish/ done button is pressed
NSLog(@"%@", skillFinalString);
LinkedInInfo = skillFinalString;
NSLog(@"%@", skillFinalString);
// Hide all social network Ui ellements from suggestion page
[self hideAllSocialPopupElements];
//save the newlly retrived data to logedinUservCard
[logedinUservCard setObject:LinkedInInfo atIndexedSubscript:9];
[logedinUservCard setObject:[NSString stringWithFormat:@""] atIndexedSubscript:1];
[self updatevCard];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"failed to fetch current user %@", error);
}];
}
- (LIALinkedInHttpClient *)client {
LIALinkedInApplication *application = [LIALinkedInApplication applicationWithRedirectURL:@"http://www.newrosoft.com/"
clientId:@"77ibz6e8ed8i53"
clientSecret:@"jkfPVSmEqGredwXO"
state:@"DCEEFWF45453sdffef424"
grantedAccess:@[@"r_fullprofile", @"r_network"]];
return [LIALinkedInHttpClient clientForApplication:application presentingViewController:nil];
}
and also i declare:
LIALinkedInHttpClient *_client;
witch takes the value:
_client = [self client];
Also I have opened a stack overflow issue.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 18
I did as same as @iazarov and finally it worked thanks…
I just removed usage of r_fullprofile, r_network in my code and it helped