From 2c4329524550e8372023483042f60e29f0196519 Mon Sep 17 00:00:00 2001 From: Prem Kumar Kalle Date: Thu, 12 Sep 2024 22:43:26 -0700 Subject: [PATCH] Fix the API Token generation URL in API token prompt Signed-off-by: Prem Kumar Kalle --- pkg/command/context.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/command/context.go b/pkg/command/context.go index 4c359e704..f02c4829e 100644 --- a/pkg/command/context.go +++ b/pkg/command/context.go @@ -1015,13 +1015,14 @@ func promptContextName(defaultCtxName string) (cname string, err error) { // Interactive way to create a TMC context. User will be prompted for CSP API token. func promptAPIToken(endpointType string) (apiToken string, err error) { - hostVal := "console.cloud.vmware.com" - if staging { - hostVal = "console-stg.cloud.vmware.com" + issuer := csp.GetIssuer(staging) + u, err := url.ParseRequestURI(issuer) + if err != nil { + return "", errors.Wrap(err, "failed to parse the issuer URL") } consoleURL := url.URL{ Scheme: "https", - Host: hostVal, + Host: u.Hostname(), Path: "/csp/gateway/portal/", Fragment: "/user/tokens", }