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 728e4a2 commit 49b5b04
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 @@ -415,7 +415,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') {
basic = btoa(credentials);
} else {
basic = new Buffer(credentials.toString(), 'binary');
}

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

Expand Down

0 comments on commit 49b5b04

Please sign in to comment.