@@ -122,7 +122,7 @@ const (
122
122
// small.
123
123
var authStyleCache struct {
124
124
sync.Mutex
125
- m map [string ]AuthStyle // keyed by tokenURL
125
+ m map [string ]AuthStyle // keyed by tokenURL+clientID
126
126
}
127
127
128
128
// ResetAuthCache resets the global authentication style cache used
@@ -135,21 +135,21 @@ func ResetAuthCache() {
135
135
136
136
// lookupAuthStyle reports which auth style we last used with tokenURL
137
137
// when calling RetrieveToken and whether we have ever done so.
138
- func lookupAuthStyle (tokenURL string ) (style AuthStyle , ok bool ) {
138
+ func lookupAuthStyle (tokenURL , clientID string ) (style AuthStyle , ok bool ) {
139
139
authStyleCache .Lock ()
140
140
defer authStyleCache .Unlock ()
141
- style , ok = authStyleCache .m [tokenURL ]
141
+ style , ok = authStyleCache .m [tokenURL + clientID ]
142
142
return
143
143
}
144
144
145
145
// setAuthStyle adds an entry to authStyleCache, documented above.
146
- func setAuthStyle (tokenURL string , v AuthStyle ) {
146
+ func setAuthStyle (tokenURL , clientID string , v AuthStyle ) {
147
147
authStyleCache .Lock ()
148
148
defer authStyleCache .Unlock ()
149
149
if authStyleCache .m == nil {
150
150
authStyleCache .m = make (map [string ]AuthStyle )
151
151
}
152
- authStyleCache .m [tokenURL ] = v
152
+ authStyleCache .m [tokenURL + clientID ] = v
153
153
}
154
154
155
155
// newTokenRequest returns a new *http.Request to retrieve a new token
@@ -192,7 +192,7 @@ func cloneURLValues(v url.Values) url.Values {
192
192
func RetrieveToken (ctx context.Context , clientID , clientSecret , tokenURL string , v url.Values , authStyle AuthStyle ) (* Token , error ) {
193
193
needsAuthStyleProbe := authStyle == 0
194
194
if needsAuthStyleProbe {
195
- if style , ok := lookupAuthStyle (tokenURL ); ok {
195
+ if style , ok := lookupAuthStyle (tokenURL , clientID ); ok {
196
196
authStyle = style
197
197
needsAuthStyleProbe = false
198
198
} else {
@@ -222,7 +222,7 @@ func RetrieveToken(ctx context.Context, clientID, clientSecret, tokenURL string,
222
222
token , err = doTokenRoundTrip (ctx , req )
223
223
}
224
224
if needsAuthStyleProbe && err == nil {
225
- setAuthStyle (tokenURL , authStyle )
225
+ setAuthStyle (tokenURL , clientID , authStyle )
226
226
}
227
227
// Don't overwrite `RefreshToken` with an empty value
228
228
// if this was a token refreshing request.
0 commit comments