-
Notifications
You must be signed in to change notification settings - Fork 598
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error-reporting: Skip authentication for error-reporting when API key is provided #2554
Conversation
} | ||
}); | ||
} else { | ||
that._logger.info('API key provided; skipping OAuth2 token generation.'); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
].join(' ')); | ||
} | ||
}); | ||
if (tryAuthenticate) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@@ -127,7 +119,9 @@ class RequestHandler extends common.Service { | |||
if (this._config.getShouldReportErrorsToAPI()) { | |||
this.request({ | |||
uri: 'events:report', | |||
qs: RequestHandler.manufactureQueryString(this._config.getKey()), | |||
qs: { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
key: 'key' | ||
}; | ||
var message = 'Made OAuth2 Token Request'; | ||
verifyReportedMessage(config, new Error(message), ''); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
].join(' ')); | ||
} | ||
}); | ||
if (tryAuthenticate) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@ofrobots PTAL. The most recent commit warns if the API key is invalid ahead of time, but depends on the error message in the response body. This works, but if you think it's too fragile I'll revert to the previous commit, which adds in the README a message informing users that the we won't be able to detect invalid API keys ahead of time. |
packages/error-reporting/README.md
Outdated
|
||
We recommend storing the API key in a file rather than hard-coding it into your application's source code. | ||
|
||
**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. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
qs: RequestHandler.manufactureQueryString(this._config.getKey()), | ||
method: 'POST', | ||
json: {} | ||
}, (err, body, response) => { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@ofrobots Another question that we should ask is: Is this something we want to support? I was of the understanding that not supporting API keys in the client libraries was an intentional decision. I am definitely hesitant to add it as a one-off in a single library. |
@lukesneeringer The API is not being added, but rather fixed in this PR. For whatever historical reasons, error-reporting started with API key support and removing it at this point is going to break existing users. I'm 👎 on that. |
@ofrobots @DominicKramer I've added a system test to check that the messages supplied from the Stackdriver Errors API are in line with what we expect. I think this is a reasonable way to act upon any future changes in the API - let me know your thoughts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM once nits are addressed.
packages/error-reporting/README.md
Outdated
|
||
If a key is provided, the module will not attempt to authenticate using the methods associated with locally-stored credentials as mentioned in the previous section. | ||
|
||
We recommend storing the API key in a file rather than hard-coding it into your application's source code. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
… is provided (googleapis#2554) PR-URL: googleapis#2554
@stephenplusplus Could you do a release of the |
Published |
Addresses #2302
When
key
is provided, the error reporting service instance doesn't go through the OAuth2 process. This means that if a provided API key is invalid, errors will never be sent (there is no fallback); however, an error will be printed in this case.