fix: user username password for login

Signed-off-by: Terry Howe <terrylhowe@gmail.com>
(cherry picked from commit 2c55a4e8ce)
pull/31037/head
Terry Howe 4 months ago committed by Robert Sirchia
parent 2782412073
commit 5b9e2f6b4c
No known key found for this signature in database
GPG Key ID: C2D40F4D8196E874

@ -289,16 +289,16 @@ func (c *Client) Login(host string, options ...LoginOption) error {
return err
}
reg.PlainHTTP = c.plainHTTP
cred := auth.Credential{Username: c.username, Password: c.password}
c.authorizer.ForceAttemptOAuth2 = true
reg.Client = c.authorizer
ctx := context.Background()
cred, err := c.authorizer.Credential(ctx, host)
if err != nil {
return fmt.Errorf("fetching credentials for %q: %w", host, err)
}
if err := reg.Ping(ctx); err != nil {
return fmt.Errorf("authenticating to %q: %w", host, err)
c.authorizer.ForceAttemptOAuth2 = false
if err := reg.Ping(ctx); err != nil {
return fmt.Errorf("authenticating to %q: %w", host, err)
}
}
// The credentialsStore loader does not handle empty files. So, there is a workaround.

Loading…
Cancel
Save