diff --git a/cmd/example-app/main.go b/cmd/example-app/main.go index 21b025d2a39a56537d919d65f55c8aa1279d7bb8..ccf9c4ca1e518e599b06ae18c2b18e6b9dd3c80f 100644 --- a/cmd/example-app/main.go +++ b/cmd/example-app/main.go @@ -237,6 +237,10 @@ func (a *app) handleLogin(w http.ResponseWriter, r *http.Request) { for _, client := range clients { scopes = append(scopes, "audience:server:client_id:"+client) } + connectorID := "" + if id := r.FormValue("connector_id"); id != "" { + connectorID = id + } authCodeURL := "" scopes = append(scopes, "openid", "profile", "email") @@ -248,6 +252,9 @@ func (a *app) handleLogin(w http.ResponseWriter, r *http.Request) { } else { authCodeURL = a.oauth2Config(scopes).AuthCodeURL(exampleAppState, oauth2.AccessTypeOffline) } + if connectorID != "" { + authCodeURL = authCodeURL + "&connector_id=" + connectorID + } http.Redirect(w, r, authCodeURL, http.StatusSeeOther) } diff --git a/cmd/example-app/templates.go b/cmd/example-app/templates.go index 3a4b5bb288705d454168e11fae6617afb3df1e14..09b4150a73ae452b6b4f805b60e1b11bbcd4269c 100644 --- a/cmd/example-app/templates.go +++ b/cmd/example-app/templates.go @@ -15,8 +15,11 @@ var indexTmpl = template.Must(template.New("index.html").Parse(`<html> <p> Extra scopes:<input type="text" name="extra_scopes" placeholder="list of scopes"> </p> - <p> - Request offline access:<input type="checkbox" name="offline_access" value="yes" checked> + <p> + Connector ID:<input type="text" name="connector_id" placeholder="connector id"> + </p> + <p> + Request offline access:<input type="checkbox" name="offline_access" value="yes" checked> </p> <input type="submit" value="Login"> </form>