From 49b5b04660061d3dba4009853f4b51a615268b51 Mon Sep 17 00:00:00 2001 From: Henrique Vicente Date: Mon, 30 Nov 2015 02:30:05 -0300 Subject: [PATCH] Fixing BasicAuth due to missing btoa(). https://github.com/nodejs/node/issues/3462 --- src/api/Launchpad.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/api/Launchpad.js b/src/api/Launchpad.js index 8a62cac..391eee0 100644 --- a/src/api/Launchpad.js +++ b/src/api/Launchpad.js @@ -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'; @@ -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); } }