我使用https://www.tumblr.com/oauth/request_token此网址获得了请求令牌(oauth_token和oauth_token_secret)。 然后我使用oauth_token构建了授权URL,这是我在上一步中获得的。 当我尝试使用我的app consumerKey,consumerSecret和oauth_token,oauth_token_secret获取访问令牌时,获取 “oauth_signature与期望值不匹配”错误消息。
为HmacSHA1构建的消息,
String signatureBaseString = "GET&" + URLEncoder.encode(accessURL, "UTF-8") + "&" + "oauth_callback%3D" + URLEncoder.encode(URLEncoder.encode(redirectUrl, "UTF-8"), "UTF-8") + "%26oauth_consumer_key%3D" + URLEncoder.encode(consumerKey, "UTF-8") + "%26oauth_nonce%3D" + URLEncoder.encode(String.valueOf(millis), "UTF-8") + "%26oauth_signature_method%3D" + URLEncoder.encode("HMAC-SHA1", "UTF-8") + "%26oauth_token%3D" + URLEncoder.encode(oauthToken, "UTF-8") + "%26oauth_timestamp%3D" + URLEncoder.encode(String.valueOf(time), "UTF-8") + "%26oauth_token_secret%3D" + URLEncoder.encode(oauthTokenSecret, "UTF-8") + "%26oauth_version%3D" + URLEncoder.encode("1.0", "UTF-8") + "%oauth_verifier%3D" + verifier;
构造头以使用请求令牌获取访问令牌
String accessHeader = "OAuth " + "oauth_callback=\"" + URLEncoder.encode(redirectUrl, "UTF-8") + "\"" + ", oauth_consumer_key=\"" + URLEncoder.encode(consumerKey, "UTF-8") + "\"" + ", oauth_nonce=\"" + URLEncoder.encode(String.valueOf(millis), "UTF-8") + "\"" + ", oauth_signature=\"" + URLEncoder.encode(signature, "UTF-8") + "\"" + ", oauth_signature_method=\"" + URLEncoder.encode("HMAC-SHA1", "UTF-8") + "\"" + ",oauth_token=\"" + URLEncoder.encode(oauthToken, "UTF-8") + "\"" + ", oauth_timestamp=\"" + URLEncoder.encode(String.valueOf(time), "UTF-8") + ",oauth_token_secret=\"" + URLEncoder.encode(oauthTokenSecret, "UTF-8") + "\"" + ", oauth_version=\"" + URLEncoder.encode("1.0", "UTF-8") + "\"" + ", oauth_verifier=\"" + verifier + "\"";
有谁可以帮我解决这个问题?