Skip to content

403 for basic auth using options.username and options.password. #1727

Answered by szmarczak
peter-snr asked this question in Q&A
Discussion options

You must be logged in to vote

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
})();

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by sindresorhus
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants