From de176cfbaa84705a45d5a732c7889994ba010c80 Mon Sep 17 00:00:00 2001 From: Hidetake Iwata Date: Mon, 3 Sep 2018 14:42:00 +0900 Subject: [PATCH] Fix refresh token is not set with Google IdP --- auth/authcode.go | 3 ++- auth/oidc.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/auth/authcode.go b/auth/authcode.go index 8186bac3..4971b966 100644 --- a/auth/authcode.go +++ b/auth/authcode.go @@ -13,6 +13,7 @@ import ( type authCodeFlow struct { Config *oauth2.Config + AuthCodeOptions []oauth2.AuthCodeOption ServerPort int // HTTP server port SkipOpenBrowser bool // skip opening browser if true } @@ -41,7 +42,7 @@ func (f *authCodeFlow) getAuthCode(ctx context.Context) (string, error) { server := http.Server{ Addr: fmt.Sprintf("localhost:%d", f.ServerPort), Handler: &authCodeHandler{ - authCodeURL: f.Config.AuthCodeURL(state), + authCodeURL: f.Config.AuthCodeURL(state, f.AuthCodeOptions...), gotCode: func(code string, gotState string) { if gotState == state { codeCh <- code diff --git a/auth/oidc.go b/auth/oidc.go index 5da689b7..2810d661 100644 --- a/auth/oidc.go +++ b/auth/oidc.go @@ -47,6 +47,7 @@ func (c *Config) GetTokenSet(ctx context.Context) (*TokenSet, error) { ServerPort: c.ServerPort, SkipOpenBrowser: c.SkipOpenBrowser, Config: oauth2Config, + AuthCodeOptions: []oauth2.AuthCodeOption{oauth2.AccessTypeOffline}, } token, err := flow.getToken(ctx) if err != nil {