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

FrisbyJS - Basic HTTP authentication #71

Closed
thesailored opened this issue Feb 21, 2014 · 4 comments
Closed

FrisbyJS - Basic HTTP authentication #71

thesailored opened this issue Feb 21, 2014 · 4 comments

Comments

@thesailored
Copy link

FrisbyJS help: I need syntax for a Basic HTTP authentication to a server using an id and password. Simple?

@vlucas
Copy link
Owner

vlucas commented Feb 21, 2014

There is an auth method that does this: https://github.com/vlucas/frisby/blob/master/lib/frisby.js#L278

@vlucas vlucas closed this as completed Feb 21, 2014
@thesailored
Copy link
Author

Uuuuuuuuuuuuu rock! I'm obviously a noob. I've been in tech 20 years...this is cool stuff. Is there any best place for learning frisby (e.g. man pages, manuals, forums)? So far all I'm finding is github is the best.

//
// HTTP Basic Auth
//
// @param string username
// @param string password
//
Frisby.prototype.auth = function(user, pass) {
authHash = new Buffer(user + ':' + pass).toString('base64');
this.addHeader('Authorization', 'Basic ' + authHash);
return this;
};

@thesailored
Copy link
Author

vlucas, Could you please provide me with more info on how to get this to work? I'm struggling with how to tell it which url to use.

var user = 'myUserName'
var password = 'thePassword'
var urlHere = 'http://myserver.net:8080';

//HTTP Basic Auth
// @param string username
// @param string password
Frisby.prototype.auth = function(user, pass) {
authHash = new Buffer(user + ':' + pass).toString('base64');
this.addHeader('Authorization', 'Basic ' + authHash);
return this;
};

@RomanManz
Copy link

Hi thesailored,

if you are still interested, if you just call the auth function after the post/put/get, then it works, e.g.
frisby.create('authorization test')
.get('http://testservice.com')
.auth('username', 'secret', false)
...

Although i am not sure what the third argument (sendImmediate) would be used for.

Regards
Roman

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

3 participants