我正在为 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();
}
}
当我运行以下代码时,它会给出如下异常
“oauth.signpost.exception.OAuthNotAuthorizedException:授权失败(服务器回复 401)。如果消费者密钥不正确或签名不匹配,则可能发生这种情况。”
在这条线上 String authUrl = provider.retrieveRequestToken(consumer, CALLBACK_URL);
我提供了正确的“密钥”和“秘密”,Twitter 是否给了我错误的密钥和秘密?