diff --git a/pkg/cmd/ssh-key/add/add.go b/pkg/cmd/ssh-key/add/add.go index 72da863de..53759acfb 100644 --- a/pkg/cmd/ssh-key/add/add.go +++ b/pkg/cmd/ssh-key/add/add.go @@ -85,12 +85,6 @@ func runAdd(opts *AddOptions) error { err = SSHKeyUpload(httpClient, hostname, keyReader, opts.Title) if err != nil { - if errors.Is(err, scopesError) { - cs := opts.IO.ColorScheme() - fmt.Fprint(opts.IO.ErrOut, "Error: insufficient OAuth scopes to list SSH keys\n") - fmt.Fprintf(opts.IO.ErrOut, "Run the following to grant scopes: %s\n", cs.Bold("gh auth refresh -s write:public_key")) - return cmdutil.SilentError - } return err } diff --git a/pkg/cmd/ssh-key/add/http.go b/pkg/cmd/ssh-key/add/http.go index c85b00c2a..28a70acc8 100644 --- a/pkg/cmd/ssh-key/add/http.go +++ b/pkg/cmd/ssh-key/add/http.go @@ -12,8 +12,6 @@ import ( "github.com/cli/cli/v2/internal/ghinstance" ) -var scopesError = errors.New("insufficient OAuth scopes") - func SSHKeyUpload(httpClient *http.Client, hostname string, keyFile io.Reader, title string) error { url := ghinstance.RESTPrefix(hostname) + "user/keys" @@ -43,9 +41,7 @@ func SSHKeyUpload(httpClient *http.Client, hostname string, keyFile io.Reader, t } defer resp.Body.Close() - if resp.StatusCode == 404 { - return scopesError - } else if resp.StatusCode > 299 { + if resp.StatusCode > 299 { var httpError api.HTTPError err := api.HandleHTTPError(resp) if errors.As(err, &httpError) && isDuplicateError(&httpError) { diff --git a/pkg/cmd/ssh-key/list/http.go b/pkg/cmd/ssh-key/list/http.go index 9a6d6fc0e..539e55bac 100644 --- a/pkg/cmd/ssh-key/list/http.go +++ b/pkg/cmd/ssh-key/list/http.go @@ -2,7 +2,6 @@ package list import ( "encoding/json" - "errors" "fmt" "io/ioutil" "net/http" @@ -12,8 +11,6 @@ import ( "github.com/cli/cli/v2/internal/ghinstance" ) -var scopesError = errors.New("insufficient OAuth scopes") - type sshKey struct { Key string Title string @@ -37,9 +34,7 @@ func userKeys(httpClient *http.Client, host, userHandle string) ([]sshKey, error } defer resp.Body.Close() - if resp.StatusCode == 404 { - return nil, scopesError - } else if resp.StatusCode > 299 { + if resp.StatusCode > 299 { return nil, api.HandleHTTPError(resp) } diff --git a/pkg/cmd/ssh-key/list/list.go b/pkg/cmd/ssh-key/list/list.go index fc35cf650..e743f2818 100644 --- a/pkg/cmd/ssh-key/list/list.go +++ b/pkg/cmd/ssh-key/list/list.go @@ -1,7 +1,6 @@ package list import ( - "errors" "fmt" "net/http" "time" @@ -59,12 +58,6 @@ func listRun(opts *ListOptions) error { sshKeys, err := userKeys(apiClient, host, "") if err != nil { - if errors.Is(err, scopesError) { - cs := opts.IO.ColorScheme() - fmt.Fprint(opts.IO.ErrOut, "Error: insufficient OAuth scopes to list SSH keys\n") - fmt.Fprintf(opts.IO.ErrOut, "Run the following to grant scopes: %s\n", cs.Bold("gh auth refresh -s read:public_key")) - return cmdutil.SilentError - } return err }