Skip to content Skip to sidebar Skip to footer

Anonymous Uploading File Object To Imgur Api (json) Gives Authentication Error 401

I've created a class UploadToImgurTask as an AsyncTask that takes a single file path parameter, creates and sets an MultiPartEntity, and then uses Apache HttpClient to upload the i

Solution 1:

From the api.imgur.com documentation, emphasis is mine:

The API requires each client to use OAuth 2 authentication. This means you'll have to register your application, and generate an access_code if you'd like to log in as a user.

For public read-only and anonymous resources, such as getting image info, looking up user comments, etc. all you need to do is send an authorization header with your client_id in your requests. This also works if you'd like to upload images anonymously (without the image being tied to an account), or if you'd like to create an anonymous album. This lets us know which application is accessing the API.

Authorization: Client-ID YOUR_CLIENT_ID

Its quite clear you need to add an authorization header to your request in order for it to work. With the Apache HttpClient its as simple as this:

httpPost.setHeader("Authorization", yourClientId);

Post a Comment for "Anonymous Uploading File Object To Imgur Api (json) Gives Authentication Error 401"