Question

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);
Was it helpful?

Solution

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!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top