LinkedIn scribe OAuth 库无法允许访问 LinkedIn 帐户 [英] LinkedIn scribe OAuth library unable to allow access to LinkedIn account

查看:37
本文介绍了LinkedIn scribe OAuth 库无法允许访问 LinkedIn 帐户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个概念验证应用程序,以使用 scribe OAuth 库连接到 LinkedIn.>

我可以获得请求令牌,但无法将其交换为访问令牌.我反复收到 oauth_problem=permission_unknown 响应,尽管点击了 LinkedIn 上的允许",当我被要求进行身份验证时,我会重定向到该响应.

我已经注册了一个回调,以便当 LinkedIn 将用户重定向到我的回调时,我的身份验证活动将恢复,并且在 onResume 我提取请求令牌和 PIN 码以用于获取访问令牌,这部分至少似乎按预期工作.

我的代码在这里:

package com.rockrobot.example.scribelinkedin;导入 org.scribe.builder.ServiceBuilder;导入 org.scribe.builder.api.LinkedInApi;导入 org.scribe.model.OAuthRequest;导入 org.scribe.model.Response;导入 org.scribe.model.Token;导入 org.scribe.model.Verb;导入 org.scribe.model.Verifier;导入 org.scribe.oauth.OAuthService;导入 android.app.Activity;导入 android.content.Intent;导入android.net.Uri;导入 android.os.Bundle;导入 android.widget.Toast;公共类登录示例扩展活动{私有静态 OAuthService 服务;私有令牌请求令牌;私人验证器验证器;private static final String PROTECTED_RESOURCE_URL = "http://api.linkedin.com/v1/people/~/connections:(id,last-name)";私有静态布尔 authInProgress = false;/** 在第一次创建活动时调用.*/@覆盖public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);如果(!authInProgress){authInProgress = 真;服务 = 新的 ServiceBuilder().provider(LinkedInApi.class).apiKey("XXXXX").apiSecret("YYYY").callback("callback://whodunit").建造();System.out.println("=== LinkedIn 的 OAuth 工作流程 ===");System.out.println();//获取请求令牌System.out.println("正在获取请求令牌...");requestToken = service.getRequestToken();System.out.println("得到请求令牌!");System.out.println();System.out.println("现在去这里授权Scribe:");System.out.println(service.getAuthorizationUrl(requestToken));Toast.makeText(this, "请授权" + getString(R.string.app_name), Toast.LENGTH_LONG).show();startActivity(新意图(Intent.ACTION_VIEW,Uri.parse(service.getAuthorizationUrl(requestToken))));}}@覆盖受保护的无效 onResume() {super.onResume();如果 (this.getIntent()!=null && this.getIntent().getData()!=null){uri uri = this.getIntent().getData();if (uri != null && uri.toString().startsWith("callback://whodunit")) {verifier = new Verifier (uri.getQueryParameter("oauth_verifier"));//用请求令牌和验证器交换访问令牌requestToken = service.getRequestToken();System.out.println("用请求令牌交换访问令牌...");System.out.println(" ---> 请求令牌:" + requestToken.getToken());System.out.println(" ---> 请求令牌秘密:" + requestToken.getSecret());System.out.println(" ---> 验证器:" + verifier.getValue());令牌 accessToken = service.getAccessToken(requestToken, verifier);System.out.println("获得访问令牌!");System.out.println("(如果你好奇它看起来像这样:" + accessToken + " )");System.out.println();//现在让我们去请求一个受保护的资源!System.out.println("现在我们要访问一个受保护的资源...");OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);service.signRequest(accessToken, request);响应 response = request.send();System.out.println("明白了!让我们看看我们发现了什么......");System.out.println();System.out.println(response.getBody());System.out.println();System.out.println("就是这样!去用 Scribe 做一些很棒的东西!:)");}}}}

我的清单中的相关摘录在这里:

 <意图过滤器><action android:name="android.intent.action.VIEW"></action><category android:name="android.intent.category.BROWSABLE"></category><category android:name="android.intent.category.DEFAULT"></category><data android:host="whodunit" android:scheme="callback"></data></意图过滤器></活动>

最后,我的 logcat 在这里:

07-05 23:39:58.204: INFO/System.out(300): === LinkedIn 的 OAuth 工作流 ===07-05 23:39:58.204:INFO/System.out(300):获取请求令牌...07-05 23:39:59.284:INFO/System.out的(300):身体=组oauth_token = 88d888e9-f05b-4b3e-ae64-97c4878cbf06&安培; oauth_token_secret = d5685691-0ff7-4c60-954c-62b9cf16028b&安培; oauth_callback_confirmed =真安培; xoauth_request_auth_url =https%3A%2F%2Fapi.linkedin.com%2Fuas%2Foauth%2Fauthorize&oauth_expires_in=59907-05 23:39:59.284:INFO/System.out(300):获得请求令牌!07-05 23:39:59.284:INFO/System.out(300):现在去这里授权 Scribe:07-05 23:39:59.294: INFO/System.out(300): https://api.linkedin.com/uas/oauth/authorize?oauth_token=88d888e9-f05b-4b3e-ae64-97c4878cbf0607-05 23:39:59.354: INFO/ActivityManager(59): 开始活动: Intent { act=android.intent.action.VIEW dat=https://api.linkedin.com/uas/oauth/authorize?oauth_token=88d888e9-f05b-4b3e-ae64-97c4878cbf06 cmp=com.android.browser/.BrowserActivity }07-05 23:39:59.484: INFO/ActivityManager(59): 为活动 com.android.browser/.BrowserActivity 启动 proc com.android.browser: pid=306 uid=10019 gids={3003, 1015}07-05 23:39:59.964: INFO/ActivityManager(59): 显示活动 com.rockrobot.example.scribelinkedin/.loginexample: 3404 ms (总 3404 ms)07-05 23:40:00.894: INFO/ActivityThread(306): 发布提供商浏览器: com.android.browser.BrowserProvider07-05 23:40:03.914: INFO/ActivityManager(59): 显示活动 com.android.browser/.BrowserActivity: 4440 ms (总 4440 ms)07-05 23:40:05.744: INFO/ActivityManager(59): 开始活动: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=https://www.linkedin.com/uas/oauth/authorize?oauth_token=88d888e9-f05b-4b3e-ae64-97c4878cbf06 cmp=com.android.browser/.BrowserActivity }07-05 23:40:14.414: INFO/ActivityManager(59): 进程 com.android.email (pid 245) 已经死亡.07-05 23:40:19.294: INFO/ActivityManager(59): 开始活动: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=callback://whodunit?oauth_token=88d888e9-f05b-4b3e-ae64-97c4878cbf06&oauth_verifier=41304 cmp=com.rockrobot.example.scribelinkedin/.loginexample }07-05 23:40:20.564:INFO/System.out的(300):身体=组oauth_token = 5362f57e-d5b5-4007-A166-d02d21e80a4d&安培; oauth_token_secret = b4d263ec-f29f-4e8b-876b-5c7a6280900f&安培; oauth_callback_confirmed =真安培; xoauth_request_auth_url =https%3A%2F%2Fapi.linkedin.com%2Fuas%2Foauth%2Fauthorize&oauth_expires_in=59907-05 23:40:20.564:INFO/System.out(300):交易请求令牌以获得访问令牌......07-05 23:40:20.564:信息/系统输出(300):--->请求令牌:5362f57e-d5b5-4007-a166-d02d21e80a4d07-05 23:40:20.564:信息/系统输出(300):--->请求令牌秘密:b4d263ec-f29f-4e8b-876b-5c7a6280900f07-05 23:40:20.564:信息/系统输出(300):--->验证者:4130407-05 23:40:21.464: INFO/System.out(300): Body = oauth_problem=permission_unknown07-05 23:40:21.514:错误/AndroidRuntime(300):致命异常:主要07-05 23:40:21.514:错误/AndroidRuntime(300):java.lang.RuntimeException:无法恢复活动{com.rockrobot.example.scribelinkedin/com.rockrobot.example.scribelinkedin.loginexample}:org.scribe.exceptions.OAuthException:响应正文不正确.无法从中提取令牌和秘密:'oauth_problem=permission_unknown'07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.app.ActivityThread.access$2300(ActivityThread.java:125)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.os.Handler.dispatchMessage(Handler.java:99)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.os.Looper.loop(Looper.java:123)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.app.ActivityThread.main(ActivityThread.java:4627)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 java.lang.reflect.Method.invokeNative(Native Method)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 java.lang.reflect.Method.invoke(Method.java:521)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 dalvik.system.NativeStart.main(Native Method)07-05 23:40:21.514:错误/AndroidRuntime(300):由:org.scribe.exceptions.OAuthException:响应正文不正确.无法从中提取令牌和秘密:'oauth_problem=permission_unknown'07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:42)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:27)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 org.scribe.oauth.OAuth10aServiceImpl.getAccessToken(OAuth10aServiceImpl.java:67)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 com.rockrobot.example.scribelinkedin.loginexample.onResume(loginexample.java:78)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.app.Activity.performResume(Activity.java:3823)07-05 23:40:21.514: 错误/AndroidRuntime(300): 在 android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)07-05 23:40:21.514: 错误/AndroidRuntime(300): ... 12 更多07-05 23:40:21.684: WARN/ActivityManager(59): 强制完成活动 com.rockrobot.example.scribelinkedin/.loginexample07-05 23:40:21.684: WARN/ActivityManager(59): 强制完成活动 com.android.browser/.BrowserActivity07-05 23:40:22.454: WARN/ActivityManager(59): HistoryRecord 的活动暂停超时{44f81be8 com.rockrobot.example.scribelinkedin/.loginexample}07-05 23:40:24.675:INFO/ActivityManager(59):进程 com.rockrobot.example.scribelinkedin (pid 300) 已经死亡.07-05 23:40:24.694: INFO/WindowManager(59): WIN DEATH: Window{450717b8 com.rockrobot.example.scribelinkedin/com.rockrobot.example.scribelinkedin.loginexample paused=false}07-05 23:40:24.914: WARN/InputManagerService(59): 在非焦点客户端 com.android.internal.view.IInputMethodClient$Stub$Proxy@4509ce80 (uid=10019 pid=306) 上启动输入

正如您在 logcat 中看到的,我获得了 oauth 令牌和 token_secret,但我无法将它们交换为访问令牌,但不断收到 oauth_problem=permission_unknown 错误.

我知道 LinkedIn 声称他们对 OAuth 的实施相当严格,但我似乎无法看看我哪里出错了 - 也许我已经盯着它看太久了,这就是你们进来的地方.

有人有什么想法吗?OAuth 并不完全简单,但我也不敢相信它这么复杂.我可能遗漏了一些明显的东西,但就是无法弄清楚它是什么.

解决方案

在您的 onResume 方法中,您将获得一个新的请求令牌,但是,验证码来自您在onCreate 方法.因此,您尝试使用第二个请求令牌获取访问令牌,但验证码对应于第一个请求令牌 - 因此,您未获得访问令牌.有道理吗?

如果你从 onResume 方法中取出 requestToken = service.getRequestToken(); 那么这应该可以正常工作,因为其他一切看起来都是正确的.

I'm writing a proof-of-concept app to connect to LinkedIn using the scribe OAuth library.

I can get a request Token, but am unable to exchange that for an access token. I am repeatedly receiving the oauth_problem=permission_unknown response, despite clicking the 'allow' on LinkedIn that I am redirected to when I am asked to authenticate.

I've registered a callback so that when LinkedIn redirects the user to my callback, my authentication activity is resumed and in onResume I extract the request token and PIN code to use to get an access token and this part at least seems to be working as intended.

My code is here:

package com.rockrobot.example.scribelinkedin;

import org.scribe.builder.ServiceBuilder;
import org.scribe.builder.api.LinkedInApi;
import org.scribe.model.OAuthRequest;
import org.scribe.model.Response;
import org.scribe.model.Token;
import org.scribe.model.Verb;
import org.scribe.model.Verifier;
import org.scribe.oauth.OAuthService;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.widget.Toast;

public class loginexample extends Activity {
    private static OAuthService service;
    private Token requestToken;
    private Verifier verifier;
    private static final String PROTECTED_RESOURCE_URL = "http://api.linkedin.com/v1/people/~/connections:(id,last-name)";
    private static Boolean authInProgress = false;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        if ( ! authInProgress ) {
            authInProgress = true;
            service = new ServiceBuilder()
                .provider(LinkedInApi.class)
                .apiKey("XXXXX")
                .apiSecret("YYYYY")
                .callback("callback://whodunit")
                .build();

            System.out.println("=== LinkedIn's OAuth Workflow ===");
            System.out.println();

            // Obtain the Request Token
            System.out.println("Fetching the Request Token...");
            requestToken = service.getRequestToken();
            System.out.println("Got the Request Token!");
            System.out.println();

            System.out.println("Now go and authorize Scribe here:");
            System.out.println(service.getAuthorizationUrl(requestToken));

            Toast.makeText(this, "Please authorize " + getString(R.string.app_name), Toast.LENGTH_LONG).show();

            startActivity (new Intent ( Intent.ACTION_VIEW, Uri.parse(service.getAuthorizationUrl(requestToken))));
        }
    }

    @Override
    protected void onResume() {  
        super.onResume();  
        if (this.getIntent()!=null && this.getIntent().getData()!=null){  
            Uri uri = this.getIntent().getData();  
            if (uri != null && uri.toString().startsWith("callback://whodunit")) {
                verifier = new Verifier ( uri.getQueryParameter("oauth_verifier") );
                    // Trade the Request Token and Verfier for the Access Token
                requestToken = service.getRequestToken();
                    System.out.println("Trading the Request Token for an Access Token...");
                    System.out.println(" ---> Request Token: " + requestToken.getToken());
                    System.out.println(" ---> Request Token Secret: " + requestToken.getSecret());
                    System.out.println(" ---> Verifier: " + verifier.getValue());
                    Token accessToken = service.getAccessToken(requestToken, verifier);
                    System.out.println("Got the Access Token!");
                    System.out.println("(if you're curious it looks like this: " + accessToken + " )");
                    System.out.println();

                    // Now let's go and ask for a protected resource!
                    System.out.println("Now we're going to access a protected resource...");
                    OAuthRequest request = new OAuthRequest(Verb.GET, PROTECTED_RESOURCE_URL);
                    service.signRequest(accessToken, request);
                    Response response = request.send();
                    System.out.println("Got it! Lets see what we found...");
                    System.out.println();
                    System.out.println(response.getBody());

                    System.out.println();
                    System.out.println("Thats it man! Go and build something awesome with Scribe! :)");
            }  
        }

    } 
}

The relevant excerpt from my Manifest is here:

    <activity android:name=".loginexample"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.VIEW"></action>
            <category android:name="android.intent.category.BROWSABLE"></category>
            <category android:name="android.intent.category.DEFAULT"></category>
            <data android:host="whodunit" android:scheme="callback"></data>
        </intent-filter>
    </activity>

Finally, my logcat is here:

07-05 23:39:58.204: INFO/System.out(300): === LinkedIn's OAuth Workflow ===
07-05 23:39:58.204: INFO/System.out(300): Fetching the Request Token...
07-05 23:39:59.284: INFO/System.out(300): Body = oauth_token=88d888e9-f05b-4b3e-ae64-97c4878cbf06&oauth_token_secret=d5685691-0ff7-4c60-954c-62b9cf16028b&oauth_callback_confirmed=true&xoauth_request_auth_url=https%3A%2F%2Fapi.linkedin.com%2Fuas%2Foauth%2Fauthorize&oauth_expires_in=599
07-05 23:39:59.284: INFO/System.out(300): Got the Request Token!
07-05 23:39:59.284: INFO/System.out(300): Now go and authorize Scribe here:
07-05 23:39:59.294: INFO/System.out(300): https://api.linkedin.com/uas/oauth/authorize?oauth_token=88d888e9-f05b-4b3e-ae64-97c4878cbf06
07-05 23:39:59.354: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.VIEW dat=https://api.linkedin.com/uas/oauth/authorize?oauth_token=88d888e9-f05b-4b3e-ae64-97c4878cbf06 cmp=com.android.browser/.BrowserActivity }
07-05 23:39:59.484: INFO/ActivityManager(59): Start proc com.android.browser for activity com.android.browser/.BrowserActivity: pid=306 uid=10019 gids={3003, 1015}
07-05 23:39:59.964: INFO/ActivityManager(59): Displayed activity com.rockrobot.example.scribelinkedin/.loginexample: 3404 ms (total 3404 ms)
07-05 23:40:00.894: INFO/ActivityThread(306): Publishing provider browser: com.android.browser.BrowserProvider
07-05 23:40:03.914: INFO/ActivityManager(59): Displayed activity com.android.browser/.BrowserActivity: 4440 ms (total 4440 ms)
07-05 23:40:05.744: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=https://www.linkedin.com/uas/oauth/authorize?oauth_token=88d888e9-f05b-4b3e-ae64-97c4878cbf06 cmp=com.android.browser/.BrowserActivity }
07-05 23:40:14.414: INFO/ActivityManager(59): Process com.android.email (pid 245) has died.
07-05 23:40:19.294: INFO/ActivityManager(59): Starting activity: Intent { act=android.intent.action.VIEW cat=[android.intent.category.BROWSABLE] dat=callback://whodunit?oauth_token=88d888e9-f05b-4b3e-ae64-97c4878cbf06&oauth_verifier=41304 cmp=com.rockrobot.example.scribelinkedin/.loginexample }
07-05 23:40:20.564: INFO/System.out(300): Body = oauth_token=5362f57e-d5b5-4007-a166-d02d21e80a4d&oauth_token_secret=b4d263ec-f29f-4e8b-876b-5c7a6280900f&oauth_callback_confirmed=true&xoauth_request_auth_url=https%3A%2F%2Fapi.linkedin.com%2Fuas%2Foauth%2Fauthorize&oauth_expires_in=599
07-05 23:40:20.564: INFO/System.out(300): Trading the Request Token for an Access Token...
07-05 23:40:20.564: INFO/System.out(300):  ---> Request Token: 5362f57e-d5b5-4007-a166-d02d21e80a4d
07-05 23:40:20.564: INFO/System.out(300):  ---> Request Token Secret: b4d263ec-f29f-4e8b-876b-5c7a6280900f
07-05 23:40:20.564: INFO/System.out(300):  ---> Verifier: 41304
07-05 23:40:21.464: INFO/System.out(300): Body = oauth_problem=permission_unknown
07-05 23:40:21.514: ERROR/AndroidRuntime(300): FATAL EXCEPTION: main
07-05 23:40:21.514: ERROR/AndroidRuntime(300): java.lang.RuntimeException: Unable to resume activity {com.rockrobot.example.scribelinkedin/com.rockrobot.example.scribelinkedin.loginexample}: org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: 'oauth_problem=permission_unknown'
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3128)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3143)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2684)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.os.Looper.loop(Looper.java:123)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.app.ActivityThread.main(ActivityThread.java:4627)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at java.lang.reflect.Method.invokeNative(Native Method)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at java.lang.reflect.Method.invoke(Method.java:521)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at dalvik.system.NativeStart.main(Native Method)
07-05 23:40:21.514: ERROR/AndroidRuntime(300): Caused by: org.scribe.exceptions.OAuthException: Response body is incorrect. Can't extract token and secret from this: 'oauth_problem=permission_unknown'
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:42)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at org.scribe.extractors.TokenExtractorImpl.extract(TokenExtractorImpl.java:27)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at org.scribe.oauth.OAuth10aServiceImpl.getAccessToken(OAuth10aServiceImpl.java:67)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at com.rockrobot.example.scribelinkedin.loginexample.onResume(loginexample.java:78)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1149)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.app.Activity.performResume(Activity.java:3823)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3118)
07-05 23:40:21.514: ERROR/AndroidRuntime(300):     ... 12 more
07-05 23:40:21.684: WARN/ActivityManager(59):   Force finishing activity com.rockrobot.example.scribelinkedin/.loginexample
07-05 23:40:21.684: WARN/ActivityManager(59):   Force finishing activity com.android.browser/.BrowserActivity
07-05 23:40:22.454: WARN/ActivityManager(59): Activity pause timeout for HistoryRecord{44f81be8 com.rockrobot.example.scribelinkedin/.loginexample}
07-05 23:40:24.675: INFO/ActivityManager(59): Process com.rockrobot.example.scribelinkedin (pid 300) has died.
07-05 23:40:24.694: INFO/WindowManager(59): WIN DEATH: Window{450717b8 com.rockrobot.example.scribelinkedin/com.rockrobot.example.scribelinkedin.loginexample paused=false}
07-05 23:40:24.914: WARN/InputManagerService(59): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@4509ce80 (uid=10019 pid=306)

As you can see in the logcat, I'm getting an oauth token and token_secret, but I am unable to exchange these for the access token but keep getting the oauth_problem=permission_unknown error.

I know LinkedIn claim to be rather strict with their implementation of OAuth, I just can't seem to see where I'm going wrong - maybe I've been staring at it for too long already, which is where you guys come in.

Does anybody have any ideas? OAuth isn't exactly simple, but I can't believe it's this complicated either. I'm probably missing something obvious, but just can't work out what it is.

解决方案

In your onResume method you're getting a new request token but, the verification code is from the request token you got in the onCreate method. So, you're trying to get an access token using the second request token but the verification code corresponds to the first request token - hence, you're not issued an access token. Make sense?

If you take out requestToken = service.getRequestToken(); from the onResume method then this should work as everything else looks correct.

这篇关于LinkedIn scribe OAuth 库无法允许访问 LinkedIn 帐户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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