From 244a3040cf042d0d68baabb27928631e08235640 Mon Sep 17 00:00:00 2001 From: Gustavo Bazan Date: Wed, 30 Mar 2022 19:09:58 +0100 Subject: [PATCH] CLOUDP-117256: Improve expired code handling --- internal/cli/auth/login.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/cli/auth/login.go b/internal/cli/auth/login.go index 9ac3c8ef48..9ab7cc0f33 100644 --- a/internal/cli/auth/login.go +++ b/internal/cli/auth/login.go @@ -16,6 +16,7 @@ package auth import ( "context" + "errors" "fmt" "os" "time" @@ -160,6 +161,10 @@ Your code will expire after %.0f minutes. } accessToken, _, err := opts.flow.PollToken(ctx, code) + var target *atlas.ErrorResponse + if errors.As(err, &target) && target.ErrorCode == "DEVICE_AUTHORIZATION_EXPIRED" { + return errors.New("authentication timed out") + } if err != nil { return err }