Skip to content

Commit

Permalink
feat!: enhance credentials usage and update warning message for crede…
Browse files Browse the repository at this point in the history
…ntials requests
  • Loading branch information
jeevatkm committed Nov 19, 2024
1 parent e10cc12 commit 9a568fc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 2 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ var (
jsonKey = "json"
xmlKey = "xml"

defaultAuthScheme = "Bearer"

hdrUserAgentValue = "go-resty/" + Version + " (https://github.com/go-resty/resty)"
bufPool = &sync.Pool{New: func() any { return &bytes.Buffer{} }}
)
Expand Down
6 changes: 1 addition & 5 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,11 +312,7 @@ func addCredentials(c *Client, r *Request) error {
// Build the token Auth header
if !isStringEmpty(r.AuthToken) {
credentialsAdded = true
authScheme := r.AuthScheme
if isStringEmpty(authScheme) {
authScheme = "Bearer"
}
r.RawRequest.Header.Set(c.HeaderAuthorizationKey(), authScheme+" "+r.AuthToken)
r.RawRequest.Header.Set(c.HeaderAuthorizationKey(), r.AuthScheme+" "+r.AuthToken)
}

if !c.IsDisableWarn() && credentialsAdded {
Expand Down
1 change: 1 addition & 0 deletions resty.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ func createClient(hc *http.Client) *Client {
queryParams: url.Values{},
formData: url.Values{},
header: http.Header{},
authScheme: defaultAuthScheme,
cookies: make([]*http.Cookie, 0),
retryWaitTime: defaultWaitTime,
retryMaxWaitTime: defaultMaxWaitTime,
Expand Down

0 comments on commit 9a568fc

Please sign in to comment.