Skip to content

Commit

Permalink
Fixing BasicAuth due to missing btoa().
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Nov 30, 2015
1 parent ec93a54 commit 91ae789
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/api/Launchpad.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import Auth from '../api/Auth';
import Auth from './Auth';
import Embodied from '../api-query/Embodied';
import Filter from '../api-query/Filter';
import Query from '../api-query/Query';
Expand Down Expand Up @@ -417,7 +417,15 @@ class Launchpad {
clientRequest.header('Authorization', 'Bearer ' + this.auth_.token());
} else {
var credentials = this.auth_.username() + ':' + this.auth_.password();
clientRequest.header('Authorization', 'Basic ' + btoa(credentials));
var basic;

if (typeof btoa === 'function') {

This comment has been minimized.

Copy link
@mairatma

mairatma Nov 30, 2015

Yeah, you're right, it's weird to have this code here, checking globals to see if it will use the browser's or node's version of binary encoding.

It'd feel better if you did something similar to what you did with io here. Making this include a module (maybe Btoa.js?) that is properly configured inside node.js and browser.js to use the right function.

basic = btoa(credentials);
} else {
basic = new Buffer(credentials.toString(), 'binary');
}

clientRequest.header('Authorization', 'Basic ' + basic);
}
}

Expand Down

0 comments on commit 91ae789

Please sign in to comment.