Reputation: 20350
I'm trying to query api.whatever.com, but I also want to pass a USERNAME, such as in curl it would look like this:
How do I write the client request in such a way that USERNAME gets sent properly to the API server.
Upvotes: 0
Views: 406
Reputation: 96
You need to base64 encode the username.
url = "https://[email protected]/".replace("https://","").split("@");
// Buffer is global, no need for require.
url64 = "https://" + (new Buffer(url[0]).toString('base64')) + url[1];
Upvotes: 1
Reputation: 45578
http://en.wikipedia.org/wiki/Basic_access_authentication
There's an explaination of the format you have to use as well as an example.
Upvotes: 1