oauth-v2-client
Version:
Oauth V2 client based on axios
22 lines (21 loc) • 752 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Generate basic authentication header value
* @param username username
* @param password password
*/
function generateBasicAuthentication(username, password) {
// we are in a node js environment
if (typeof Buffer !== 'undefined') {
return "Basic ".concat(Buffer.from("".concat(username, ":").concat(password)).toString("base64"));
}
else if (typeof btoa === "function") {
// browser environemnt
return "Basic ".concat(btoa("".concat(username, ":").concat(password)));
}
else {
throw new Error('Unable to create the base 64 string.');
}
}
exports.default = generateBasicAuthentication;