diff --git a/netbox.go b/netbox.go index f2ba069..7d79744 100644 --- a/netbox.go +++ b/netbox.go @@ -86,6 +86,9 @@ type Client struct { // Token is set for authentication of the API Token string + // TokenPrefix is optional to set token prefix other than "Token" + TokenPrefix string + // SessionKey is used to read authentication data SessionKey string @@ -282,7 +285,11 @@ func (c *Client) newRequest(ctx context.Context, method, path string, query stri } if c.Token != "" { - req.Header.Add("Authorization", "Bearer "+c.Token) + req.Header.Add("Authorization", "Token "+c.Token) + } + + if c.Token != "" && c.TokenPrefix != "" { + req.Header.Add("Authorization", c.TokenPrefix+" "+c.Token) } if c.SessionKey != "" {