Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yesoreyeram committed Feb 3, 2025
1 parent 12ced35 commit 7bba1e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 2 additions & 4 deletions clientcredentials/clientcredentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ func (c *tokenSource) Token() (*oauth2.Token, error) {
RefreshToken: tk.RefreshToken,
Expiry: tk.Expiry,
}
if c.conf != nil {
t.CustomTokenHeaderKey = c.conf.CustomTokenHeaderKey
t.CustomTokenPrefix = c.conf.CustomTokenPrefix
}
t.CustomTokenHeaderKey = c.conf.CustomTokenHeaderKey
t.CustomTokenPrefix = c.conf.CustomTokenPrefix
return t.WithExtra(tk.Raw), nil
}
6 changes: 2 additions & 4 deletions jwt/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,7 @@ func (js jwtSource) Token() (*oauth2.Token, error) {
}
token.AccessToken = tokenRes.IDToken
}
if js.conf != nil {
token.CustomTokenHeaderKey = js.conf.CustomTokenHeaderKey
token.CustomTokenPrefix = js.conf.CustomTokenPrefix
}
token.CustomTokenHeaderKey = js.conf.CustomTokenHeaderKey
token.CustomTokenPrefix = js.conf.CustomTokenPrefix
return token, nil
}
6 changes: 3 additions & 3 deletions token.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ func (t *Token) SetAuthHeader(r *http.Request) {
if strings.TrimSpace(t.CustomTokenHeaderKey) != "" {
headerKey = t.CustomTokenHeaderKey
}
headerValue := strings.TrimSpace(strings.Join([]string{t.Type(), t.AccessToken}, " "))
headerValue := t.Type() + " " + t.AccessToken
if t.CustomTokenPrefix != "" {
headerValue = strings.TrimSpace(strings.Join([]string{t.CustomTokenPrefix, headerValue}, ""))
headerValue = t.CustomTokenPrefix + t.AccessToken
}
r.Header.Set(headerKey, headerValue)
r.Header.Set(headerKey, strings.TrimSpace(headerValue))
}

// WithExtra returns a new Token that's a clone of t, but using the
Expand Down

0 comments on commit 7bba1e2

Please sign in to comment.