Getting a 403 from BufferedReader

吃可爱长大的小学妹 提交于 2019-12-24 02:41:17

问题


I'm trying to upload an image to imgur, I am getting a response from the site but it returns me with

null : {"data":{"error":"Malformed auth header","request":"/3/image","parameters":"image = iVBORw0KGgoAAAANSUhEUgAAB4AAAASwCAIAAACVUsChAACAAElEQVR42uzdCXebyrI2YEuyY8fzPCbZOyfZd597v///...","method":"POST"},"success":false,"status":403}

A 403 error on the imgur documentation says

Forbidden. You don't have access to this action. If you're getting this error, check that you haven't run out of API credits or make sure you're sending the OAuth headers correctly and have valid tokens/secrets.

I know that the secret is valid and that I have enough credits which means I'm not sending the OAuth header properly.

post.addHeader("Authorization", "Client-ID" + clientID);

The solution for anyone wondering was that that line was supposed to be

post.addHeader("Authorization", "Client-ID " + clientID);

回答1:


I believe you are missing the space between the "Client-ID" string and the actual client id. Try to replace this:

    post.addHeader("Authorization", "Client-ID" + clientID);

with

    post.addHeader("Authorization", "Client-ID " + clientID);

As the official Imgur authentication documentation says to set the header like this:

Authorization: Client-ID YOUR_CLIENT_ID

Hope it works!



来源:https://stackoverflow.com/questions/17391486/getting-a-403-from-bufferedreader

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