Skip to content

Commit 7bba1e2

Browse files
committed
cleanup
1 parent 12ced35 commit 7bba1e2

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

clientcredentials/clientcredentials.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,7 @@ func (c *tokenSource) Token() (*oauth2.Token, error) {
126126
RefreshToken: tk.RefreshToken,
127127
Expiry: tk.Expiry,
128128
}
129-
if c.conf != nil {
130-
t.CustomTokenHeaderKey = c.conf.CustomTokenHeaderKey
131-
t.CustomTokenPrefix = c.conf.CustomTokenPrefix
132-
}
129+
t.CustomTokenHeaderKey = c.conf.CustomTokenHeaderKey
130+
t.CustomTokenPrefix = c.conf.CustomTokenPrefix
133131
return t.WithExtra(tk.Raw), nil
134132
}

jwt/jwt.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ func (js jwtSource) Token() (*oauth2.Token, error) {
187187
}
188188
token.AccessToken = tokenRes.IDToken
189189
}
190-
if js.conf != nil {
191-
token.CustomTokenHeaderKey = js.conf.CustomTokenHeaderKey
192-
token.CustomTokenPrefix = js.conf.CustomTokenPrefix
193-
}
190+
token.CustomTokenHeaderKey = js.conf.CustomTokenHeaderKey
191+
token.CustomTokenPrefix = js.conf.CustomTokenPrefix
194192
return token, nil
195193
}

token.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ func (t *Token) SetAuthHeader(r *http.Request) {
102102
if strings.TrimSpace(t.CustomTokenHeaderKey) != "" {
103103
headerKey = t.CustomTokenHeaderKey
104104
}
105-
headerValue := strings.TrimSpace(strings.Join([]string{t.Type(), t.AccessToken}, " "))
105+
headerValue := t.Type() + " " + t.AccessToken
106106
if t.CustomTokenPrefix != "" {
107-
headerValue = strings.TrimSpace(strings.Join([]string{t.CustomTokenPrefix, headerValue}, ""))
107+
headerValue = t.CustomTokenPrefix + t.AccessToken
108108
}
109-
r.Header.Set(headerKey, headerValue)
109+
r.Header.Set(headerKey, strings.TrimSpace(headerValue))
110110
}
111111

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

0 commit comments

Comments
 (0)