-
Notifications
You must be signed in to change notification settings - Fork 388
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
GoogleAuth ignores credentials passed to it in getClient in favor of cached credentials #390
Comments
Greetings! This does look like a bug. As a workaround, you can instantiate a new const auth = new GoogleAuth({
...
}); We will take a look at a proper fix! |
Thank you. That was the solution I came up with as well: this._promiseGoogleAuthClient = (new GoogleAuth({
credentials: this._dialogflowCredentials,
scopes: this._requiredGoogleScopes
})).getClient(/* options here are always ignored b/c cache */); |
How would you tell if the credentials match without reading in the content? Would you just compare their keyFilenames? |
Stumbled upon the same issue when using googleapis. I don't see any reason why this library should cache the auth client except from premature optimization. I suggest that the If caching the auth is a necessary feature however, I propose the following (breaking) changes:
I assume that removing the cache would be a breaking change anyway, because people's applications might slow down. Edit: After digging a bit deeper I partly revoke my proposal. Memoizing the client inside the |
The getClient method in GoogleAuth will ignore any credentials passed to it if it has cached credentials, regardless of differences between the credentials passed in the parameter and the credentials that have been cached:
https://github.com/google/google-auth-library-nodejs/blob/0ff24c7c4a1c5da604dd2019dfc225a922934e3e/src/auth/googleauth.ts#L656-L675
As far as I can find, there is no way to actually clear the cached credentials once it has been set. (Aside from manually explicitly setting the property to null, which doesn't feel right to me).
I'd imagine ideally that if the credentials didn't match, the cached ones would be ignored.
I'd expect at least some way to bust the cache; possibly as a property in the options parameter (something like
useCachedCredentials: boolean
).The text was updated successfully, but these errors were encountered: