fix: use getRequestHeaders instead of getRequestMetadata

This commit is contained in:
Alexander Fenster 2018-09-13 10:25:23 -07:00 committed by murgatroid99
parent 0cf120a663
commit d78c49a648
2 changed files with 9 additions and 8 deletions

View File

@ -39,7 +39,7 @@
"body-parser": "^1.15.2",
"electron-mocha": "^3.1.1",
"express": "^4.14.0",
"google-auth-library": "^0.9.2",
"google-auth-library": "^2.0.0",
"google-protobuf": "^3.0.0",
"istanbul": "^0.4.4",
"lodash": "^4.17.4",

View File

@ -195,16 +195,17 @@ exports.createFromMetadataGenerator = function(metadata_generator) {
exports.createFromGoogleCredential = function(google_credential) {
return exports.createFromMetadataGenerator(function(auth_context, callback) {
var service_url = auth_context.service_url;
google_credential.getRequestMetadata(service_url, function(err, header) {
if (err) {
google_credential.getRequestHeaders(service_url)
.then(function(header) {
var metadata = new Metadata();
metadata.add('authorization', header.Authorization);
callback(null, metadata);
})
.catch(function(err) {
common.log(constants.logVerbosity.INFO, 'Auth error:' + err);
callback(err);
return;
}
var metadata = new Metadata();
metadata.add('authorization', header.Authorization);
callback(null, metadata);
});
});
});
};