-
Hi, I am trying out this library and would like to know how to execute a request using basic authentication. My curl request that works fine is:
But my request using got fails with a 403.
This is returning a 403 response code. I also tried to set the auth header but that failed as well. Really do not want to revert to the request library if I can help it. Thanks in advance, any examples would be most appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I cannot reproduce: const got = require('got');
(async () => {
const result = await got('https://httpbin.org/anything', {
username: 'hello',
password: 'world'
}).json();
const valid = Buffer.from(result.headers.Authorization.split(' ')[1], 'base64').toString() === 'hello:world';
console.log(valid); //=> true
})(); |
Beta Was this translation helpful? Give feedback.
-
Hi, after further analysis, the url is a web server login and requires cookies. I will try again, thank you for testing. |
Beta Was this translation helpful? Give feedback.
I cannot reproduce: