Skip to content

Commit b76f424

Browse files
committed
handle SG OAuth token format
1 parent e7e3abb commit b76f424

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

internal/api/api.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,12 @@ func (c *client) createHTTPRequest(ctx context.Context, method, p string, body i
169169
req.Header.Set("User-Agent", "src-cli/"+version.BuildTag)
170170
}
171171
if c.opts.AccessToken != "" {
172-
req.Header.Set("Authorization", "token "+c.opts.AccessToken)
172+
// If this is a SG OAuth access token, then we need to use "Bearer <token>"
173+
if strings.HasPrefix(c.opts.AccessToken, "sgo_at_") {
174+
req.Header.Set("Authorization", "Bearer "+c.opts.AccessToken)
175+
} else {
176+
req.Header.Set("Authorization", "token "+c.opts.AccessToken)
177+
}
173178
}
174179
if *c.opts.Flags.trace {
175180
req.Header.Set("X-Sourcegraph-Should-Trace", "true")

0 commit comments

Comments
 (0)