Skip to content

Commit a0cb79a

Browse files
committed
Print details of authentication workaround to terminal
Mitigates cli#297 This adds some more information to the output when authentication fails due to `gh` being unable to open a browser. It communicates the details of the workaround without the user having to search issues on the `gh` repo to see how to get around it.
1 parent 39bdeee commit a0cb79a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

auth/oauth.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,13 @@ func (oa *OAuthFlow) ObtainAccessToken() (accessToken string, err error) {
5656
oa.logf("open %s\n", startURL)
5757
if err := openInBrowser(startURL); err != nil {
5858
fmt.Fprintf(os.Stderr, "error opening web browser: %s\n", err)
59+
fmt.Fprintf(os.Stderr, "")
5960
fmt.Fprintf(os.Stderr, "Please open the following URL manually:\n%s\n", startURL)
61+
fmt.Fprintf(os.Stderr, "")
62+
// TODO: Temporary workaround for https://github.com/cli/cli/issues/297
63+
fmt.Fprintf(os.Stderr, "If you are on a server or other headless system, use this workaround instead:")
64+
fmt.Fprintf(os.Stderr, " 1. Complete authentication on a GUI system")
65+
fmt.Fprintf(os.Stderr, " 2. Copy the contents of ~/.config/gh/config.yml to this system")
6066
}
6167

6268
http.Serve(listener, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)