-
Notifications
You must be signed in to change notification settings - Fork 1k
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
google: panic in (TokenSource).Token()
as returned by google.CredentialsFromJSONWithParams
#583
Comments
I will try to handle it and submit a PR. |
@espadolini It seems that The
From my point of view, the best way to fix it, is to provide a default implementation of I will begin to work on a PR tomorrow (it's late at home !), and we will see if the Go team agree with this fix. |
Maybe |
@espadolini I have to admit that this is not something ideal (Even if I think, reading the example, that it was design with that purposed in mind :/ ), but just returning an error is weird too. Such situation is not a non nominal case, but a coding error, and may not be handle programmatically. A I can imagine two ways of fixing that more or less properly : 1 panic if 3LO and nil handler + deprecation on CredentialsFromJSON (with meaningful message in the panic). 2 way to register a 3LO AuthHandler alongside CredentialsParams + panic if 3LO and all AuthHandler are nil The second one, is clearly the most complex, and I am unsure, considering the current design, that it is desirable : it seems that I am not very happy with the first one, but with the |
If a "Google Developers Console client_credentials.json" file is parsed by
google.CredentialsFromJSONWithParams
then theTokenSource
for theCredentials
returned is aTokenSource
from theauthhandler
package, whoseToken()
method will ultimately call theparams.AuthHandler
callback without ever checking that it's non-nil. The only way to specify such a callback is through theparams
argument toCredentialsFromJSONWithParams
orFindDefaultCredentialsWithParams
, so there's no workaround if one were to useCredentialsFromJSON
(which only gets some scopes as a string slice) or theDefaultTokenSource
/FindDefaultCredentials
functions.Reproducible example:
go version go1.19 darwin/arm64
golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094 (latest at time of writing)
The bug is present as far back as v0.0.0-20220411215720-9780585627b5, I haven't tried other platforms or versions other than those two, but the bug seems fairly straightforward to trigger.
FYI, it's also not very clear what the
AuthHandler
function is supposed to be doing, and there's no examples for it.The text was updated successfully, but these errors were encountered: