Skip to content

Commit

Permalink
error msg instead if the api key is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
kjin committed Aug 23, 2017
1 parent 89a0ec5 commit 689a233
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/error-reporting/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ If a key is provided, the module will not attempt to authenticate using the meth

We recommend storing the API key in a file rather than hard-coding it into your application's source code.
**Note:** If the API key provided is invalid, an error will be logged the first time the Error Reporting instance attempts to report an error. To ensure that the API key is valid, you may want to attempt to trigger an error shortly after deploying your app.
**Note:** The Error Reporting instance will check if the provided API key is invalid shortly after it is instantiated. If the key is invalid, an error-level message will be logged.
## Configuration
Expand Down
13 changes: 13 additions & 0 deletions packages/error-reporting/src/google-apis/auth-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ class RequestHandler extends common.Service {
}
});
} else {
this.request({
uri: 'events:report',
qs: RequestHandler.manufactureQueryString(this._config.getKey()),
method: 'POST',
json: {}
}, (err, body, response) => {
if (err && err.message !== 'Message cannot be empty.') {
this._logger.error([
'Encountered an error while attempting to validate the provided',
'API key'
].join(' '), err);
}
});
that._logger.info('API key provided; skipping OAuth2 token request.');
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function verifyReportedMessage(config, errToReturn, expectedLogs) {
cb(errToReturn);
}
};
this.request = function() {};
}
}

Expand Down

0 comments on commit 689a233

Please sign in to comment.