@@ -183,6 +183,7 @@ func (c *client) createHTTPRequest(ctx context.Context, method, p string, body i
183183 } else {
184184 req .Header .Set ("User-Agent" , "src-cli/" + version .BuildTag )
185185 }
186+
186187 if c .opts .AccessToken != "" {
187188 req .Header .Set ("Authorization" , "token " + c .opts .AccessToken )
188189 }
@@ -264,10 +265,20 @@ func (r *request) do(ctx context.Context, result any) (bool, error) {
264265 // confirm the status code. You can test this easily with e.g. an invalid
265266 // endpoint like -endpoint=https://google.com
266267 if resp .StatusCode != http .StatusOK {
267- if resp .StatusCode == http .StatusUnauthorized && isatty .IsCygwinTerminal (os .Stdout .Fd ()) {
268- fmt .Println ("You may need to specify or update your access token to use this endpoint." )
269- fmt .Println ("See https://github.com/sourcegraph/src-cli#readme" )
270- fmt .Println ("" )
268+ if resp .StatusCode == http .StatusUnauthorized {
269+ if oauth .IsOAuthTransport (r .client .httpClient .Transport ) {
270+ fmt .Println ("The OAuth token is invalid. Please check that the Sourcegraph CLI client is still authorized." )
271+ fmt .Println ("" )
272+ fmt .Println ("To re-authorize, run: src login" )
273+ fmt .Println ("" )
274+ fmt .Println ("Learn more at https://github.com/sourcegraph/src-cli#readme" )
275+ fmt .Println ("" )
276+ }
277+ if isatty .IsCygwinTerminal (os .Stdout .Fd ()) {
278+ fmt .Println ("You may need to specify or update your access token to use this endpoint." )
279+ fmt .Println ("See https://github.com/sourcegraph/src-cli#readme" )
280+ fmt .Println ("" )
281+ }
271282 }
272283 body , err := io .ReadAll (resp .Body )
273284 if err != nil {
0 commit comments