feat(#10): Support http-access-tokens for authentication

This commit is contained in:
xvlcwk
2024-02-07 23:26:35 +01:00
committed by chris
parent 8f9c46f7d7
commit 5c82693906
4 changed files with 47 additions and 32 deletions

View File

@@ -40,6 +40,7 @@ type BitbucketClient struct {
Server string
Username string
Password string
Token string
HTTPClient *http.Client
}
@@ -60,7 +61,11 @@ func (c *BitbucketClient) Do(method, endpoint string, payload *bytes.Buffer, con
return nil, err
}
req.SetBasicAuth(c.Username, c.Password)
if c.Password != "" {
req.SetBasicAuth(c.Username, c.Password)
} else {
req.Header.Add("Authorization", "Bearer "+c.Token)
}
req.Header.Add("X-Atlassian-Token", "no-check")
if payload != nil {