Search code examples
node.jsimgur

imgur malformed auth header


I am using "request" trying this example

const request = require('request');
request(
  {
    url: 'https://api.imgur.com/3/gallery/hot/top/day/0',
    headers: {
      Authorization: { 'Client-ID': '04e2c49522b2562' },
    },
  },
  (e, r, body) => {
    console.log(body);
  },
);

receiving this error:

"data":{"error":"Malformed auth header","request":"\/3\/gallery\/hot\/top\/day\/0","method":"GET"},"success":false,"status":403}

Solution

  • Instead of setting the Authorization header as an object, try setting it as a string:

    Authorization: 'Client-ID 04e2c49522b2562',
    

    For further details, see Custom HTTP Headers.