相关疑难解决方法(0)

请求令牌上的android twitter retrieveRequestToken 401

我正在为twitter oauth尝试以下示例应用程序.

http://www.androidsdkforum.com/android-sdk-development/3-oauth-twitter.html

private void askOAuth() {
        try {
            consumer = new CommonsHttpOAuthConsumer(CONSUMER_KEY, CONSUMER_SECRET);
            provider = new DefaultOAuthProvider("http://twitter.com/oauth/request_token",
                                                "http://twitter.com/oauth/access_token",
                                                "http://twitter.com/oauth/authorize");
            String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
            Toast.makeText(this, "Please authorize this app!", Toast.LENGTH_LONG).show();
            this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(authUrl)));
        } catch (Exception e) {
            Log.e(APP, e.getMessage());
            Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show();
        }
    }
Run Code Online (Sandbox Code Playgroud)

当我运行以下代码时,它给出了如下异常

"oauth.signpost.exception.OAuthNotAuthorizedException:授权失败(服务器回复401).如果消费者密钥不正确或签名不匹配,就会发生这种情况."

在这条线上 String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);

我提供了正确的"密钥"和"秘密",Twitter是否给了我错误的密钥和秘密?

android twitter4j

13
推荐指数
3
解决办法
8420
查看次数

标签 统计

android ×1

twitter4j ×1