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

Cannot specify auth in initialization object #31

Closed
carlosduclos opened this issue Mar 17, 2017 · 3 comments
Closed

Cannot specify auth in initialization object #31

carlosduclos opened this issue Mar 17, 2017 · 3 comments

Comments

@carlosduclos
Copy link
Contributor

Original issue

timwis
I'd like to pass a username and password to nano without storing it in the couchdb url string, so that the url string can be used in other parts of the application that require separate authentication. The documentation suggests I can pass an auth object into the requestDefaults property of the initialization object, like this:

var db = require('nano')({
url: 'http://localhost:5984',
requestDefaults: {
auth: { user: 'admin', pass: 'foo' }
}
})
But this seems to have no effect on the request, resulting in the standard 401 unauthorized error. Passing the same user/pass as part of the url (http://admin:foo@localhost:5984) works fine.

In the meantime, I'm getting around this using a function that deconstructs the url, adds in the user/pass, and reconstructs it. But I'd prefer this cleaner approach.

I also tried upgrading the version of request and I think I did it correctly... Am I doing it wrong or is this a bug?

timwis
may be related to #278

@wprater
Copy link

wprater commented Jun 15, 2017

still broken?

@PlkMarudny
Copy link

Probably it should be:

authorization : { 
    username: 'admin',
    password: 'admin'
}

But it still does not work.

@big-r81
Copy link
Contributor

big-r81 commented Jun 20, 2022

Hi,

does nano.auth work?

@big-r81 big-r81 closed this as completed Jun 20, 2022
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

4 participants