Laur Stefan
Laur Stefan

Reputation: 1579

iOS LinkedIn API error

I am trying to implement this LinkedIn library in my project, but it seems that I get an error while I try to present the LinkedIn screen:

Authorization failed LinkedIn1: Error Domain=LIALinkedInERROR Code=1 "The operation couldn’t be completed. (LIALinkedInERROR error 1.)"

You can find the code that I am using here.

Upvotes: 2

Views: 2879

Answers (5)

Kunal Gupta
Kunal Gupta

Reputation: 3074

I also faced the same problem .My error was Error Domain=LIALinkedInERROR Code=2. On 26th May , 2016 the Linkedin has again made some changes due to which extra '#!' are added to the state and as a result ,the state do not match in LIALinkedInAuthorizationViewController class. So the solution is to remove those 2 characters either by replacing string or by checking contain string.

In the else part of this method - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {

change to `

      NSString *receivedState = [[self extractGetParameter:@"state" fromURLString: url] stringByReplacingOccurrencesOfString:@"#!" withString:@""];

` or apply contains string so that the state is matched completely.

I know its kind of a weird solution but that did the trick for me. Hope it helps you as well. All the best

enter image description here

Upvotes: 11

user6469824
user6469824

Reputation: 21

You should have to use:

code=https://www.linkedin.com/oauth/v2/authorization?

In place of:

code=https://www.linkedin.com//uas/oauth2/authorization?

Also in linkedin api:

LIALinkedInAuthorizationViewController.m
LIALinkedInHttpClient

Change:

NSString *accessTokenUrl = @"/uas/oauth2/accessToken?grant_type=authorization_code&code=%@&redirect_uri=%@&client_id=%@&client_secret=%@";

By:

NSString *accessTokenUrl = @"/oauth/v2/accessToken?grant_type=authorization_code&code=%@&redirect_uri=%@&client_id=%@&client_secret=%@";

Upvotes: 2

Ahmet Kazim Günay
Ahmet Kazim Günay

Reputation: 1062

Jack's answer is absolutely true, Jack's Answer. In addition to this you can use this library also LinkedinIOSHelper , it is easy to use

Upvotes: 0

Jack Dewhurst
Jack Dewhurst

Reputation: 349

Since the 12th May Linkedin's API has changed. From now on any apps requesting r_contactinfo must be approved by LinkedIn. This link explains the changes.

I'm using this Library and just had to change the permissions from @"r_contactinfo" to @"r_basicprofile", @"r_emailaddress".

Also remember to change your app permissions on developer.linkedin.com to match the above.

Upvotes: 3

Vijay Masiwal
Vijay Masiwal

Reputation: 1153

May this information help you -

enter image description here

API Terms of Use

Transition Guide

Upvotes: 5

Related Questions