Add ability to set custom token prefix
This commit is contained in:
parent
e23a54368e
commit
b054d32835
1 changed files with 8 additions and 1 deletions
|
@ -86,6 +86,9 @@ type Client struct {
|
||||||
// Token is set for authentication of the API
|
// Token is set for authentication of the API
|
||||||
Token string
|
Token string
|
||||||
|
|
||||||
|
// TokenPrefix is optional to set token prefix other than "Token"
|
||||||
|
TokenPrefix string
|
||||||
|
|
||||||
// SessionKey is used to read authentication data
|
// SessionKey is used to read authentication data
|
||||||
SessionKey string
|
SessionKey string
|
||||||
|
|
||||||
|
@ -282,7 +285,11 @@ func (c *Client) newRequest(ctx context.Context, method, path string, query stri
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.Token != "" {
|
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 != "" {
|
if c.SessionKey != "" {
|
||||||
|
|
Loading…
Reference in a new issue