Marlowe
Marlowe

Reputation: 33

nodejs node-libcurl HTTP Authorisation - problems with Bearer Auth Token

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?

Upvotes: 1

Views: 691

Answers (1)

derpirscher
derpirscher

Reputation: 17382

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'])

Upvotes: 0

Related Questions