LinkedIn的API错误无效的签名在iPhone入门套件 [英] Linkedin API Error Invalid Signature in iPhone Starter Kit

查看:233
本文介绍了LinkedIn的API错误无效的签名在iPhone入门套件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行OAuthStarterKit X code ++项目开箱即用,输入了正确的API密钥/秘密和OAuth用户令牌/秘密。当我到了这个code授权:

I've tried to run the OAuthStarterKit xcode project out of the box, entered the correct api key/secret and oauth user token/secret. When I get to authorizing with this code:

    OAMutableURLRequest *request = 
        [[[OAMutableURLRequest alloc] initWithURL:requestTokenURL
                                         consumer: self.consumer
                                            token: self.requestToken   
                                         callback:linkedInCallbackURL
                                signatureProvider:sha] autorelease];

这将返回错误signature_invalid,这似乎预示着一个不正确的签名。明文和密有大写和小写字符的组合,我不知道,应该有所作为。

It returns the error "signature_invalid", which seems to indicate an incorrect signature. the clear text and secret have a mix of upper and lower case chars, I'm not sure that that should make a difference.

如果我用

requestTokenURLString = @"https://api.linkedin.com/uas/oauth/requestToken?scope=r_basicprofile+r_emailaddress";

它返回无效的信号...但如果​​我使用一个基本的权限调用

It returns invalid sig... but if I use a basic permissions call

requestTokenURLString = @"https://api.linkedin.com/uas/oauth/requestToken;

它工作正常,但它意味着我只需要基本的配置文件的权限,在那里我需要像电子邮件地址的东西。

It works fine, but it means I only have basic profile permissions, where I need things like the email address.

输入所有在测试控制台的同一数据似乎很好地工作在这里:

Entering all of the same data in the test console seems to work fine here:

https://developer.linkedin.com/oauth-test-console

任何人都知道我应该做的事情,思考,或者我应该寻找?
进一步的日志信息:

Anyone know what I should be doing, thinking, or where I should be looking? Further log info:

oauth_problem=signature_invalid
oauth_problem_advice=com.linkedin.security.auth.pub.LoginDeniedInvalidAuthTokenException while obtaining request token for: POST https://api.linkedin.com/uas/oauth/requestToken/oauth_callback:hdlinked://linkedin/oauth 
oauth_consumer_key: XXX
oauth_nonce
oauth_signature_method: 3DHMACSHA1

2012-09-04 23:36:07.054 OAuthStarterKit[31952:c07] secret: TIDi9XXXXXXX
2012-09-04 23:36:07.054 OAuthStarterKit[31952:c07] base64EncodedResult: JXW6ZWUpXv7ba98o2hcUXodDhmg=

我使用的是code样品从这里 https://开头github上。 COM /针杆/ LinkedIn-OAuth的样本客户端

编辑:将试图让这个未来的底部,并回答我的问题,如果没人打我吧。

Will be trying to get to the bottom of this tomorrow and answer my own question if no one beats me to it.

推荐答案

与LinkedIn的API野兽多扯皮之后,我发现这个问题是在事物都设有codeD,说来话长,在OAuthLoginView。米法requestTokenFromProvider我需要包括在OARequestParameter对象中的相关权限参数范围。

After much wrangling with the Linkedin API Beast, I found the issue to be in the way things are encoded, a long story, in OAuthLoginView.m in method 'requestTokenFromProvider' I needed to include the param 'scope' with the relevant permissions in a OARequestParameter object.

(基于该GitHub库 - > https://github.com/synedra/ LinkedIn-OAuth的样本客户端

(based off the github repo -> https://github.com/synedra/LinkedIn-OAuth-Sample-Client)

在这之后,无论你正在做你的API调用,(在OAuthStarterKit为例)像ProfileTabView :: profileApiCall可以断火网址的帖子是这样的:的 http://api.linkedin.com/v1/people/~:(ID,直呼其名,最后-name,行业)];
或者如果你需要他们的电子邮件地址,它出现(只要你有权限访问电子邮件,你可以抓住太简单,如这样的:

After that, wherever you're making your api call, (in OAuthStarterKit for example) like in ProfileTabView::profileApiCall you can fire off URL posts like this: http://api.linkedin.com/v1/people/~:(id,first-name,last-name,industry)"]; or if you need their email address, it appears (as long as you've got permission to access email, you can grab that too as simply as this:

NSURL *url = [NSURL URLWithString:@"http://api.linkedin.com/v1/people/~:(id,first-name,last-name,industry,email-address)"];

查看code在下面的URL请求使用OARequestParameter ...

See the code for using a OARequestParameter in the URL request below...

- (void)requestTokenFromProvider
{
    OAMutableURLRequest *request = 
            [[[OAMutableURLRequest alloc] initWithURL:requestTokenURL
                                             consumer:self.consumer
                                                token:nil   
                                             callback:linkedInCallbackURL
                                    signatureProvider:nil] autorelease];

    [request setHTTPMethod:@"POST"];

    OARequestParameter * scopeParameter=[OARequestParameter requestParameter:@"scope" value:@"r_fullprofile r_contactinfo r_emailaddress"];

    [request setParameters:[NSArray arrayWithObject:scopeParameter]];

    OADataFetcher *fetcher = [[[OADataFetcher alloc] init] autorelease];
    [fetcher fetchDataWithRequest:request
                         delegate:self
                didFinishSelector:@selector(requestTokenResult:didFinish:)
                  didFailSelector:@selector(requestTokenResult:didFail:)];    
}

和一个更深入的捷径使用LinkedIn的API我会继续我的博客有些quicktips在这里 - > http://techrantnz.blogspot.com.au/2012/09/the-linkedin-api-with -oauthstarterkit.html

And for a more in depth short cut to using linkedin's API I'll keep some quicktips on my blog here ->http://techrantnz.blogspot.com.au/2012/09/the-linkedin-api-with-oauthstarterkit.html

如果你想检查一切正常,检查它是否成功,这就是所谓的方法

If you wish to check things are working, check the method which is called if it succeeds

- (void)profileApiCallResult:(OAServiceTicket *)ticket didFinish:(NSData *)data

如果您的输出响应主体可能会看到类似这样的:

If you output the response body you might see something like:

2012-09-05 21:40:55.109 OAuthStarterKit[12244:c07] profile: {
    emailAddress = "[my email]@gmail.com";
    firstName = Dave;
    id = XXXXXX;
    industry = "Information Technology and Services";
    lastName = "XXXXXXXX";
}

这篇关于LinkedIn的API错误无效的签名在iPhone入门套件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆