【问题标题】:Linkedin API 401 [unauthorized]. (iOS with OAuthStarterKit) ErrorLinkedin API 401 [未经授权]。 (带有 OAuthStarterKit 的 iOS)错误
【发布时间】:2017-01-24 23:20:11
【问题描述】:

我在尝试从我的 iPhone 应用发布状态更新时收到了此回复。而且我不知道自己做错了什么,我一直在进出文档,数据包嗅探,linkedin 论坛和代码与 Linkedin API 怪物战斗,但我无法克服这个错误,并希望知道的任何人提供任何关于我可以做些什么来解决和/或解决这个问题的建议:

data: <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<error>
<status>401</status>
<timestamp>1349234286875</timestamp>
<request-id>ZAAVLR7K6H</request-id>
<error-code>0</error-code>
<message>[unauthorized]. OAUxxxxxxxx-xxxxxxxx|*xx|*xx:xxxxxxxx:lxxxxxxxxxxxxxxxx=</message>
</error>

我请求这些权限:r_fullprofile r_contactinfo r_emailaddress, rw_nus 以获得授权。

图形路径设置为:

http://api.linkedin.com/v1/people/~/shares

授权后我的基本签名如下:

POST&http%3A%2F%2Fapi.linkedin.com%2Fv1%2Fpeople%2F~%2Fshares&oauth_consumer_key%3Diws9c2xtzgdr%26oauth_nonce%xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1349234713%26oauth_token%xxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx%26oauth_version%3D1.0

我调用的主要代码如下:

- (void) updateStatus : (NSString *) status{
if (self.consumer != nil) {
OAMutableURLRequest *request =
[[OAMutableURLRequest alloc] initWithURL: requestURL
consumer: self.consumer
token: self.accessToken
callback: nil
signatureProvider: nil];

NSMutableDictionary *permsDict = [NSMutableDictionary dictionary];

[permsDict setValue: @"anyone" forKey: @"code"];

NSMutableDictionary *shareJSONDict = [NSMutableDictionary dictionary];

[shareJSONDict setValue: permsDict forKey: @"visibility"];
[shareJSONDict setValue: @"test" forKey: @"comment"];

[request setValue:@"application/json" forHTTPHeaderField:@"x-li-format"];

NSString *updateString = [shareJSONDict JSONString];

[request setHTTPBodyWithString:updateString];
[request setHTTPMethod:@"POST"];

OADataFetcher *fetcher = [[OADataFetcher alloc] init];

[fetcher fetchDataWithRequest: request
delegate: self.sessionDelegate
didFinishSelector: @selector(postUpdateApiCallResult:didFinish:)
didFailSelector: @selector(postUpdateApiCallResult:didFail:)];
}
}

到目前为止,我花了 12 个小时与 Linkedin API 争论,我需要做的就是获取用户的基本信息并能够在 Linkedin 上分享,而在 Facebook 和 Twitter 上花了 30 秒。

【问题讨论】:

  • 你有没有想过这个问题?

标签: ios api linkedin


【解决方案1】:

首先,r_fullprofile, r_contactinfo, rw_nus 不允许在您的应用程序的基本配置文件中使用。如果你想使用它们,你必须订阅LinkedIN Partnership Programs

其次,你要开启w_share的权限。

【讨论】:

    猜你喜欢
    • 2013-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-01
    • 2019-05-06
    • 1970-01-01
    • 2016-02-09
    • 1970-01-01
    相关资源
    最近更新 更多