简体   繁体   中英

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 .

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

在此输入图像描述

May this information help you -

在此输入图像描述

API Terms of Use

Transition Guide

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.

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=%@";

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM