Authorization failed LinkedIn1: Error Domain=LIALinkedInERROR Code=1 "The operation couldn’t be completed. (LIALinkedInERROR error 1.)"
daisoreanu opened this issue · comments
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.
Likeswise, this problem has started occurring since LinkedIn's new API terms of use changed on the 12th May.
Same thing happened here, I've debugged the library a little bit and it appears that LinkedIn is refusing connections. Look at the response URL:
http://site.us/?error=invalid_scope&error_description=Your+application+has+not+been+authorized+for+the+scope+%22r_fullprofile%22
I've found the necessary changes here: https://developer.linkedin.com/support/developer-program-transition
Changes introduced on this new version of the API basically block you from a lot of stuff.
I'm getting the same error. Is it clear now how to fix or workaround the issue?
I just removed usage of r_fullprofile, r_network in my code and it helped
I'm getting the same error. Is it clear now how to fix or workaround the issue?
@KetaniPhone You can only use r_basicprofile, r_emailaddress.
I am also getting same error as @vishaldeshai .
Have you resolved this issue?
Authorization failed Error Domain=LIALinkedInERROR Code=2 "(null)"
Yes, i have resolved that issue. @ddksaku
--> LIALinkedInAuthorizationViewController.m File
// if ([self.application.state isEqualToString:receivedState]) {
if([receivedState rangeOfString:self.application.state].location != NSNotFound){
Description--> application state changed with two extra character, so string is not match with 'isEqualToString'. you have to comment one line and change 'rangeOfString' function.
if you put break point then you can see exact problem.
Vishal
Thanks for your help. @vishaldeshai
I have put break point there and get the result. the returned state code was different with original one.
original one is "afjkjagjak31kjakfj", and returned one is "afjkjagjak31kjakfj#!". returned has more 2 characters "#!" than original one.
How can I solve this issue?
thanks again.
i already write two line of code in my message please replace
Ah, yes. checked now.
Thanks
have your issue cleared?
Yes, thanks again.