Remove Sts prefix in the request name as it is duplicate with the package

This commit is contained in:
Jin Qin 2023-09-28 00:42:26 +00:00
parent c50beac896
commit 6e2aaff345
3 changed files with 5 additions and 5 deletions

View File

@ -208,7 +208,7 @@ func (ts tokenSource) Token() (*oauth2.Token, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
stsRequest := stsexchange.StsTokenExchangeRequest{ stsRequest := stsexchange.TokenExchangeRequest{
GrantType: "urn:ietf:params:oauth:grant-type:token-exchange", GrantType: "urn:ietf:params:oauth:grant-type:token-exchange",
Audience: conf.Audience, Audience: conf.Audience,
Scope: conf.Scopes, Scope: conf.Scopes,

View File

@ -28,7 +28,7 @@ func defaultHeader() http.Header {
// The first 4 fields are all mandatory. headers can be used to pass additional // The first 4 fields are all mandatory. headers can be used to pass additional
// headers beyond the bare minimum required by the token exchange. options can // headers beyond the bare minimum required by the token exchange. options can
// be used to pass additional JSON-structured options to the remote server. // be used to pass additional JSON-structured options to the remote server.
func ExchangeToken(ctx context.Context, endpoint string, request *StsTokenExchangeRequest, authentication ClientAuthentication, headers http.Header, options map[string]interface{}) (*Response, error) { func ExchangeToken(ctx context.Context, endpoint string, request *TokenExchangeRequest, authentication ClientAuthentication, headers http.Header, options map[string]interface{}) (*Response, error) {
data := url.Values{} data := url.Values{}
data.Set("audience", request.Audience) data.Set("audience", request.Audience)
data.Set("grant_type", "urn:ietf:params:oauth:grant-type:token-exchange") data.Set("grant_type", "urn:ietf:params:oauth:grant-type:token-exchange")
@ -99,8 +99,8 @@ func makeRequest(ctx context.Context, endpoint string, data url.Values, authenti
return &stsResp, nil return &stsResp, nil
} }
// StsTokenExchangeRequest contains fields necessary to make an oauth2 token exchange. // TokenExchangeRequest contains fields necessary to make an oauth2 token exchange.
type StsTokenExchangeRequest struct { type TokenExchangeRequest struct {
ActingParty struct { ActingParty struct {
ActorToken string ActorToken string
ActorTokenType string ActorTokenType string

View File

@ -22,7 +22,7 @@ var auth = ClientAuthentication{
ClientSecret: clientSecret, ClientSecret: clientSecret,
} }
var exchangeTokenRequest = StsTokenExchangeRequest{ var exchangeTokenRequest = TokenExchangeRequest{
ActingParty: struct { ActingParty: struct {
ActorToken string ActorToken string
ActorTokenType string ActorTokenType string