1

I'm coding a nodejs app to retrieve a transcript file from a site via the API.
If I use a curl command line everything works fine but I'm getting an

"Authoristaion Required"

status code back from my nodejs code.

I'm using the "node-libcurl" library and I'm trying to pass the Authorisation code by:

const curl = new Curl();
.....
curl.setopt(Curl.option.XOAUTH2_BEARER, "xxxxxxxxxxxxxxxxx");
.....

where xxxxxxxxxxxxxxxx is the Bearer authorization code. Is this syntax incorrect?

Suyash Gaur
  • 2,481
  • 2
  • 9
  • 22
Marlowe
  • 33
  • 4
  • Please show the working curl commandline ... With a typical Bearer authentication, you would simply set the `Authorization: Bearer xxxxxxxxx` header ... – derpirscher Aug 27 '21 at 19:41
  • The working command line includes: -H "Authorization: Bearer xxxxxxxxxxxxxxxxxx" as you say simply sets the authorization. But how do you do that in Node.js? – Marlowe Aug 28 '21 at 18:53

1 Answers1

0

You have to set the same headers as in your working call from the cli. According to the docs this should do the trick

curl.setOpt(Curl.option.HTTPHEADER, ['Authorization: Bearer xxxxx'])
derpirscher
  • 14,418
  • 3
  • 18
  • 35