You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I have multiple processes working with the same clientId and token, I need to make sure both processes are exactly in sync, knowing about the latest token, and grabbing an exclusive lock before trying to refresh the token. But this use case doesn't seem to be supported in OAuth2Client. For example, the docstrings describe that the request can be retried if it fails due to an expired token, so .credentials could change without me knowing for a while. And there doesn't seem to be an obvious place to insert an exclusive lock to prevent two processes from trying to refresh the token at the same time. The most obvious route seems to be to subclass OAuth2Client, override OAuth2Client.prototype.getRequestMetadata, and reimplement that method to grab the token out of a file and also grab an exclusive lock before trying to refresh. But the method calls the private this.refreshToken_. I could call this.refreshAccessToken instead, but it is deprecated.
Is this the right approach, or should I be looking elsewhere?
If it is, I think some tweaks could make this easier for the user to implement, e.g. if OAuth2Client.prototype.getRequestMetadata called a public overrideable method instead of this.refreshToken_; then I could just override that method instead of getRequestMetadata. I think this.credentials would also need to be replaced with an overrideable method that calls a callback with the latest credentials. That seems like a bigger change.
The text was updated successfully, but these errors were encountered:
If I have multiple processes working with the same clientId and token, I need to make sure both processes are exactly in sync, knowing about the latest token, and grabbing an exclusive lock before trying to refresh the token. But this use case doesn't seem to be supported in
OAuth2Client
. For example, the docstrings describe that the request can be retried if it fails due to an expired token, so.credentials
could change without me knowing for a while. And there doesn't seem to be an obvious place to insert an exclusive lock to prevent two processes from trying to refresh the token at the same time. The most obvious route seems to be to subclassOAuth2Client
, overrideOAuth2Client.prototype.getRequestMetadata
, and reimplement that method to grab the token out of a file and also grab an exclusive lock before trying to refresh. But the method calls the privatethis.refreshToken_
. I could callthis.refreshAccessToken
instead, but it is deprecated.Is this the right approach, or should I be looking elsewhere?
If it is, I think some tweaks could make this easier for the user to implement, e.g. if
OAuth2Client.prototype.getRequestMetadata
called a public overrideable method instead ofthis.refreshToken_
; then I could just override that method instead ofgetRequestMetadata
. I thinkthis.credentials
would also need to be replaced with an overrideable method that calls a callback with the latest credentials. That seems like a bigger change.The text was updated successfully, but these errors were encountered: