Basic Auth options parsing #253

Closed
ticup opened this Issue Jan 5, 2012 · 4 comments

4 participants

@ticup

Hi,

I wanted to try the basic auth func added in #202.
But it gives following error. (also when I simply use the code given in the 202 pull request)
I shortly gave it a look and apparantly it fails at parsing the options correctly for the credentials and @credentials.scheme is undefined.

setup:
node: v 0.6.6
npm 1-1-0-beta-4
zombie: latest through "npm install zombie"

error message:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot call method 'toLowerCase' of undefined
at History._resource (/Users/tim/Documents/workspaceNode/EssenCrawler/node_modules/zombie/lib/zombie/history.coffee:108:36)
at History._pageChanged (/Users/tim/Documents/workspaceNode/EssenCrawler/node_modules/zombie/lib/zombie/history.coffee:60:21)
at History._assign (/Users/tim/Documents/workspaceNode/EssenCrawler/node_modules/zombie/lib/zombie/history.coffee:213:19)
at /Users/tim/Documents/workspaceNode/EssenCrawler/node_modules/zombie/lib/zombie/browser.coffee:333:30
at Browser.withOptions (/Users/tim/Documents/workspaceNode/EssenCrawler/node_modules/zombie/lib/zombie/browser.coffee:107:14)
at Browser.visit (/Users/tim/Documents/workspaceNode/EssenCrawler/node_modules/zombie/lib/zombie/browser.coffee:327:12)
at Function.visit (/Users/tim/Documents/workspaceNode/EssenCrawler/node_modules/zombie/lib/zombie/index.coffee:13:33)
at Object. (/Users/tim/Documents/workspaceNode/EssenCrawler/test.js:12:8)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)

Thanks.

@assaf
Owner

Your credentials should look like this:

credentials: { scheme: "basic", username: "bloody", password: "hungry" }
@ticup

that explains it, thanks a lot.

Maybe there should be 3 lines of doc about this somewhere?

Suggestion: On the API page there is:

Browser Options

You can use the following options:

credentials -- Object containing authorization credentials.

add:

credentials -- Object containing authorization credentials. The object should contain following information: { scheme: ('Basic' | 'Digest'), username: 'username', password: 'password' }.

@assaf assaf closed this in d79974b Jan 12, 2012
@mypark

just gave this a try and I got a funny error, if I pass username and password, password is correctly set but username is undefined in the auth header, if I pass user and password, username is correctly set but password is just p... if I pass username, password, and user, then it finally seems to work.

credentials: {
scheme: "basic",
user: "test",
username:"test",
password: "pwd"
}

@rustedgrail

I was passing in just username and password and got a 401 error (authentication). User and password worked though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment