google: Make state configurable in DefaultAuthorizationHandler

This commit is contained in:
Andy Zhao
2020-06-04 22:27:52 -07:00
parent ceaa866219
commit 04f020b1f2
2 changed files with 24 additions and 9 deletions

View File

@@ -220,13 +220,13 @@ type AuthorizationHandler func(string) (string, string, error)
// An environment-specific AuthorizationHandler is used to obtain user consent.
// Per OAuth protocol, a unique "state" string should be sent and verified
// before token exchange to prevent CSRF attacks.
func OAuthClientTokenSource(config oauth2.Config, ctx context.Context, authHandler AuthorizationHandler, state string) oauth2.TokenSource {
func OAuthClientTokenSource(ctx context.Context, config *oauth2.Config, authHandler AuthorizationHandler, state string) oauth2.TokenSource {
return oauth2.ReuseTokenSource(nil, oauthClientSource{config: config, ctx: ctx, authHandler: authHandler, state: state})
}
type oauthClientSource struct {
config oauth2.Config
ctx context.Context
config *oauth2.Config
authHandler AuthorizationHandler
state string
}