From abaf51e66bcc9fdbc45d520eab7804923e63e6b1 Mon Sep 17 00:00:00 2001 From: Will Vedder Date: Tue, 6 Dec 2022 16:49:40 -0500 Subject: [PATCH] Minor changes --- internal/auth/token.go | 10 ++++++---- internal/cli/cli.go | 10 +++++----- internal/cli/login.go | 5 +++-- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/internal/auth/token.go b/internal/auth/token.go index 122b5b137..7cd964d80 100644 --- a/internal/auth/token.go +++ b/internal/auth/token.go @@ -32,10 +32,12 @@ func (t *TokenRetriever) Delete(tenant string) error { // The request is used the default client_id and endpoint for device authentication. func (t *TokenRetriever) Refresh(ctx context.Context, tenant string) (TokenResponse, error) { // get stored refresh token: - refreshToken, err := t.Secrets.Get(SecretsNamespace, tenant) - if err != nil { - return TokenResponse{}, fmt.Errorf("cannot get the stored refresh token: %w", err) - } + // refreshToken, err := t.Secrets.Get(SecretsNamespace, tenant) + // if err != nil { + // return TokenResponse{}, fmt.Errorf("cannot get the stored refresh token: %w", err) + // } + + refreshToken := "fadsfasdf" if refreshToken == "" { return TokenResponse{}, errors.New("cannot use the stored refresh token: the token is empty") } diff --git a/internal/cli/cli.go b/internal/cli/cli.go index acf8c6104..9b0f63813 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -217,13 +217,13 @@ func (c *cli) prepareTenant(ctx context.Context) (Tenant, error) { } if err := t.regenerateAccessToken(ctx, c); err != nil { - // Ask and guide the user through the login process. - if t.authenticatedWithDeviceCodeFlow() { - c.renderer.Warnf("Failed to renew access token. Please sign in to re-authenticate the CLI.") - return RunLoginAsUser(ctx, c) + if t.authenticatedWithClientCredentials() { + return t, fmt.Errorf("Failed to renew access token. This may occur if the designated application has been deleted or client secret has been rotated. Please re-authenticate by running `auth0 login --as-machine`") } - return t, fmt.Errorf("Failed to renew access token. This may occur if the designated application has been deleted or client secret has been rotated. Please re-authenticate by running `auth0 login --as-machine`") + c.renderer.Warnf("Failed to renew access token. Please sign in to re-authenticate the CLI.") + return RunLoginAsUser(ctx, c) + } if err := c.addTenant(t); err != nil { diff --git a/internal/cli/login.go b/internal/cli/login.go index 12ef40d5a..f1a8a2360 100644 --- a/internal/cli/login.go +++ b/internal/cli/login.go @@ -66,11 +66,12 @@ auth0 login --domain --client-id --client-secret