From d30ad5d47939cb81f2a18c9b5ffa2866de826a3a Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Thu, 16 Nov 2017 06:48:40 -0700 Subject: [PATCH] Don't assume first value is non-url format. (#467) The first entry can be OTP shared secret or the URL. This fixes --- action/otp.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/action/otp.go b/action/otp.go index 560020a1cd..f398d6bda1 100644 --- a/action/otp.go +++ b/action/otp.go @@ -50,7 +50,12 @@ func (s *Action) OTP(ctx context.Context, c *cli.Context) error { secKey = sec.Password() } - otp, err = twofactor.NewGoogleTOTP(secKey) + if strings.HasPrefix(secKey, "otpauth://") { + otp, label, err = twofactor.FromURL(secKey) + } else { + otp, err = twofactor.NewGoogleTOTP(secKey) + } + if err != nil { return s.exitError(ctx, ExitUnknown, err, "No OTP entry found for %s", name) }