|
func NewClient(ctx context.Context, src TokenSource) *http.Client { |
While using oauth2.NewClient, I expected that errors related to token retrieval or refresh would surface during client creation. However, the client would be constructed successfully even if TokenSource would later fail.
It appears that token retrieval only happens lazily when the client performs a request via Transport.
It might be helpful to clarify this behavior in the documentation for oauth2.NewClient and/or Config.Client, since users may expect token validation to happen when the client is created.
oauth2/oauth2.go
Line 353 in 4d954e6
While using
oauth2.NewClient, I expected that errors related to token retrieval or refresh would surface during client creation. However, the client would be constructed successfully even ifTokenSourcewould later fail.It appears that token retrieval only happens lazily when the client performs a request via
Transport.It might be helpful to clarify this behavior in the documentation for
oauth2.NewClientand/orConfig.Client, since users may expect token validation to happen when the client is created.