@@ -15,6 +15,7 @@ import (
1515 "github.com/docker/cli/cli/internal/oauth/api"
1616 "github.com/docker/docker/registry"
1717 "github.com/morikuni/aec"
18+ "github.com/sirupsen/logrus"
1819
1920 "github.com/pkg/browser"
2021)
@@ -70,6 +71,8 @@ func New(options OAuthManagerOptions) *OAuthManager {
7071 }
7172}
7273
74+ var ErrDeviceLoginStartFail = errors .New ("failed to start device code flow login" )
75+
7376// LoginDevice launches the device authentication flow with the tenant,
7477// printing instructions to the provided writer and attempting to open the
7578// browser for the user to authenticate.
@@ -80,11 +83,13 @@ func New(options OAuthManagerOptions) *OAuthManager {
8083func (m * OAuthManager ) LoginDevice (ctx context.Context , w io.Writer ) (* types.AuthConfig , error ) {
8184 state , err := m .api .GetDeviceCode (ctx , m .audience )
8285 if err != nil {
83- return nil , fmt .Errorf ("failed to get device code: %w" , err )
86+ logrus .Debugf ("failed to start device code login: %v" , err )
87+ return nil , ErrDeviceLoginStartFail
8488 }
8589
8690 if state .UserCode == "" {
87- return nil , errors .New ("no user code returned" )
91+ logrus .Debugf ("failed to start device code login: missing user code" )
92+ return nil , ErrDeviceLoginStartFail
8893 }
8994
9095 _ , _ = fmt .Fprintln (w , aec .Bold .Apply ("\n USING WEB BASED LOGIN" ))
0 commit comments