From 6277cf24c6558e72a29527651b05a826f699200b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Richard=20Nordstr=C3=B6m?= Date: Sun, 1 Sep 2024 20:17:07 +0200 Subject: [PATCH] allow no OAuth in case PAT is used --- cmd/auth/logout.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/auth/logout.go b/cmd/auth/logout.go index 586d37ef4..506c97ee2 100644 --- a/cmd/auth/logout.go +++ b/cmd/auth/logout.go @@ -6,6 +6,7 @@ import ( "fmt" "io/fs" + "github.com/databricks/cli/libs/auth/cache" "github.com/databricks/cli/libs/auth" "github.com/databricks/cli/libs/cmdio" "github.com/databricks/cli/libs/databrickscfg" @@ -98,8 +99,14 @@ func newLogoutCommand(persistentAuth *auth.PersistentAuth) *cobra.Command { if err != nil { return err } - if err := LogoutSession.clearTokenCache(ctx); err != nil { - return err + err = LogoutSession.clearTokenCache(ctx) + if err != nil { + if errors.Is(err, cache.ErrNotConfigured) { + // It is OK to not have OAuth configured. Move on and remove + // sensitive values example PAT from config file + } else { + return err + } } if err := LogoutSession.clearConfigFile(ctx, configSectionMap); err != nil { return err