Skip to content

Commit 9fd2420

Browse files
Merge pull request #907 from stephenplusplus/spp--util-unauthorized-api-requests
core: emit auto-auth errors
2 parents fe2f2e1 + ad8bdc5 commit 9fd2420

File tree

2 files changed

+1
-27
lines changed

2 files changed

+1
-27
lines changed

lib/common/util.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -337,13 +337,7 @@ function makeAuthenticatedRequestFactory(config) {
337337
}
338338

339339
function onAuthenticated(err, authenticatedReqOpts) {
340-
// google-auth-library returns a "Could not load..." error if it can't get
341-
// an access token. However, it's possible an API request doesn't need to
342-
// be authenticated, e.g. when downloading a file from a public bucket. We
343-
// consider this error a warning, and allow the request to go through
344-
// without authentication, relying on the upstream API to return an error
345-
// the user would find more helpful, should one occur.
346-
if (err && err.message.indexOf('Could not load') === -1) {
340+
if (err) {
347341
if (stream) {
348342
stream.destroy(err);
349343
} else {

test/common/util.js

-20
Original file line numberDiff line numberDiff line change
@@ -535,26 +535,6 @@ describe('common/util', function() {
535535
};
536536
});
537537

538-
it('should not care about "Could not load" errors', function(done) {
539-
var error = new Error('Could not load');
540-
541-
utilOverrides.decorateRequest = function() {};
542-
543-
authClient.authorizeRequest = function(rOpts, callback) {
544-
setImmediate(function() {
545-
callback(error);
546-
});
547-
};
548-
549-
var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory();
550-
makeAuthenticatedRequest({}, {
551-
onAuthenticated: function(err) {
552-
assert.strictEqual(err, null);
553-
done();
554-
}
555-
});
556-
});
557-
558538
it('should invoke the callback with error', function(done) {
559539
var makeAuthenticatedRequest = util.makeAuthenticatedRequestFactory();
560540
makeAuthenticatedRequest({}, function(err) {

0 commit comments

Comments
 (0)