Skip to content

Commit b755d64

Browse files
authored
Only set Authorization when token is available (#3789)
1 parent 12cbac6 commit b755d64

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

github/github.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,9 @@ func (c *Client) WithAuthToken(token string) *Client {
355355
c2.client.Transport = roundTripperFunc(
356356
func(req *http.Request) (*http.Response, error) {
357357
req = req.Clone(req.Context())
358-
req.Header.Set("Authorization", fmt.Sprintf("Bearer %v", token))
358+
if token != "" {
359+
req.Header.Set("Authorization", fmt.Sprintf("Bearer %v", token))
360+
}
359361
return transport.RoundTrip(req)
360362
},
361363
)

0 commit comments

Comments
 (0)