Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about authorization #1376

Closed
yosiasz opened this issue Jul 23, 2020 · 2 comments
Closed

Question about authorization #1376

yosiasz opened this issue Jul 23, 2020 · 2 comments

Comments

@yosiasz
Copy link

yosiasz commented Jul 23, 2020

What would you like to discuss?

got.post
...

Checklist

  • [ x] I have read the documentation.
    Hello,

What may I be missing here for a simple POST that is throwing a 401?

Thanks!

          const options = {
              https: { rejectUnauthorized: settings.ssl },
              headers: {
                    'Accept': 'application/json', 
                    'Content-Type': 'application/json',
                    'vmware-use-header-authn': settings.username,
                    'vmware-api-session-id': undefined,                    
                  },
              username: settings.username,
              password: settings.password,              
            }
        
          const response = await got.post(url, options);
@szmarczak
Copy link
Collaborator

#1351 and/or #1169. Try passing an authorization header instead.

@szmarczak szmarczak changed the title Basic POST question Question about authorization Jul 23, 2020
@yosiasz
Copy link
Author

yosiasz commented Jul 23, 2020

Thanks @szmarczak !! That did the trick!

          const options = {
              https: { rejectUnauthorized: settings.ssl },
              headers: {
                'Authorization': "Basic " + Buffer.from(settings.username + ':' + settings.password).toString("base64"),
                'Content-Type': 'application/json',
                'Accept': 'application/json',
                'vmware-api-session-id': undefined,              
                }          
            }

          const response = await got.post(url, options);

@yosiasz yosiasz closed this as completed Jul 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants