diff --git a/internal/config/profile.go b/internal/config/profile.go index 460260aa66..6725b3eb42 100644 --- a/internal/config/profile.go +++ b/internal/config/profile.go @@ -54,6 +54,7 @@ const ( RefreshTokenField = "refresh_token" ClientIDField = "client_id" OpsManagerURLField = "ops_manager_url" + AccountURLField = "account_url" baseURL = "base_url" apiVersion = "api_version" output = "output" @@ -470,6 +471,12 @@ func (p *Profile) SetOpsManagerURL(v string) { p.Set(OpsManagerURLField, v) } +// AccountURL gets the configured account base url. +func AccountURL() string { return Default().AccountURL() } +func (p *Profile) AccountURL() string { + return p.GetString(AccountURLField) +} + // ProjectID get configured project ID. func ProjectID() string { return Default().ProjectID() } func (p *Profile) ProjectID() string { diff --git a/internal/oauth/oauth.go b/internal/oauth/oauth.go index 70b1f47a8e..b7798ac172 100644 --- a/internal/oauth/oauth.go +++ b/internal/oauth/oauth.go @@ -29,6 +29,7 @@ type ServiceGetter interface { Service() string OpsManagerURL() string ClientID() string + AccountURL() string } const ( @@ -50,7 +51,10 @@ func FlowWithConfig(c ServiceGetter, client *http.Client) (*auth.Config, error) auth.SetClientID(id), auth.SetScopes([]string{"openid", "profile", "offline_access"}), } - if configURL := c.OpsManagerURL(); configURL != "" { + + if configURL := c.AccountURL(); configURL != "" { + authOpts = append(authOpts, auth.SetAuthURL(configURL)) + } else if configURL := c.OpsManagerURL(); configURL != "" { authOpts = append(authOpts, auth.SetAuthURL(c.OpsManagerURL())) } else if c.Service() == config.CloudGovService { authOpts = append(authOpts, auth.SetAuthURL(cloudGovServiceURL))