Getting 401 (Not Authorized), when calling Tumblr post reblog api

拟墨画扇 提交于 2019-12-10 16:13:02

问题


I am getting 401 status when calling Tumblr post reblog api, other tumblr api working fine.

I followed some of Stackoverflow links but can't get ride on it.

constantly-getting-401-when-trying-to-post-to-tumblr-blog

tumblr-oauth-image-post-gives-me-401-invalid-oauth-credentials

My code snippets :

String url = String.format(REBLOG_URL, blogName);

HttpPost request = new HttpPost(url);

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("id", postId));
nameValuePairs.add(new BasicNameValuePair("reblog_key", reblogKey));
nameValuePairs.add(new BasicNameValuePair("comment", comment));
nameValuePairs.add(new BasicNameValuePair("api_key", consumerKey));

request.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));

CommonsHttpOAuthConsumer consumer = new CommonsHttpOAuthConsumer(consumerKey, secretKey);
                                consumer.setTokenWithSecret(mDataStore.getAccessToken(mUserSequenceId),
                    mDataStore.getTokenSecret(mUserSequenceId));
consumer.sign(request);

String response = makePostRequest(request);

L.d(TAG, "postReblog Response : " + response);

Error Output :

10-21 21:48:31.851: W/DefaultRequestDirector(30729):
Authentication error: Unable to respond to any of these challenges: {}
10-21 21:48:31.851: D/PhotoAPI(30729): post response code:401 10-21
21:48:31.861: D/PhotoAPI(30729): Post response :
{"meta":{"status":401,"msg":"Not Authorized"},"response":[]}

Thanks in advance.

来源:https://stackoverflow.com/questions/19502277/getting-401-not-authorized-when-calling-tumblr-post-reblog-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!