@@ -146,13 +146,13 @@ func WithGrantType(grantType string) grantTypeOption {
146146type resourceOption []string
147147
148148func (resource resourceOption ) ApplyOauth2CredentialsOption (c * oauth2TokenExchange ) error {
149- c .resource = resource
149+ c .resource = append ( c . resource , resource ... )
150150
151151 return nil
152152}
153153
154- func WithResource (resource ... string ) resourceOption {
155- return resource
154+ func WithResource (resource string , resources ... string ) resourceOption {
155+ return append ([] string { resource }, resources ... )
156156}
157157
158158// RequestedTokenType
@@ -172,26 +172,26 @@ func WithRequestedTokenType(requestedTokenType string) requestedTokenTypeOption
172172type audienceOption []string
173173
174174func (audience audienceOption ) ApplyOauth2CredentialsOption (c * oauth2TokenExchange ) error {
175- c .audience = audience
175+ c .audience = append ( c . audience , audience ... )
176176
177177 return nil
178178}
179179
180- func WithAudience (audience ... string ) audienceOption {
181- return audience
180+ func WithAudience (audience string , audiences ... string ) audienceOption {
181+ return append ([] string { audience }, audiences ... )
182182}
183183
184184// Scope
185185type scopeOption []string
186186
187187func (scope scopeOption ) ApplyOauth2CredentialsOption (c * oauth2TokenExchange ) error {
188- c .scope = scope
188+ c .scope = append ( c . scope , scope ... )
189189
190190 return nil
191191}
192192
193- func WithScope (scope ... string ) scopeOption {
194- return scope
193+ func WithScope (scope string , scopes ... string ) scopeOption {
194+ return append ([] string { scope }, scopes ... )
195195}
196196
197197// RequestTimeout
@@ -573,7 +573,7 @@ func (cfg *oauth2TokenSourceConfig) applyConfigFixedJWT(tokenSrcType int) (*toke
573573 }
574574
575575 if cfg .Audience != nil && len (cfg .Audience .Values ) > 0 {
576- opts = append (opts , WithAudience (cfg .Audience .Values ... ))
576+ opts = append (opts , WithAudience (cfg .Audience .Values [ 0 ], cfg . Audience . Values [ 1 :] ... ))
577577 }
578578
579579 if cfg .ID != "" {
@@ -623,15 +623,15 @@ func (cfg *oauth2Config) applyConfig(opts *[]Oauth2TokenExchangeCredentialsOptio
623623 }
624624
625625 if cfg .Resource != nil && len (cfg .Resource .Values ) > 0 {
626- * opts = append (* opts , WithResource (cfg .Resource .Values ... ))
626+ * opts = append (* opts , WithResource (cfg .Resource .Values [ 0 ], cfg . Resource . Values [ 1 :] ... ))
627627 }
628628
629629 if cfg .Audience != nil && len (cfg .Audience .Values ) > 0 {
630- * opts = append (* opts , WithAudience (cfg .Audience .Values ... ))
630+ * opts = append (* opts , WithAudience (cfg .Audience .Values [ 0 ], cfg . Audience . Values [ 1 :] ... ))
631631 }
632632
633633 if cfg .Scope != nil && len (cfg .Scope .Values ) > 0 {
634- * opts = append (* opts , WithScope (cfg .Scope .Values ... ))
634+ * opts = append (* opts , WithScope (cfg .Scope .Values [ 0 ], cfg . Scope . Values [ 1 :] ... ))
635635 }
636636
637637 if cfg .RequestedTokenType != "" {
@@ -1153,7 +1153,7 @@ func WithSubject(subject string) subjectOption {
11531153
11541154// Audience
11551155func (audience audienceOption ) ApplyJWTTokenSourceOption (s * jwtTokenSource ) error {
1156- s .audience = audience
1156+ s .audience = append ( s . audience , audience ... )
11571157
11581158 return nil
11591159}
0 commit comments