google: clean up tests and add godoc comments

Change-Id: I54d2702a149d1eccd64f8ef2ed4b4617429c9358
This commit is contained in:
Patrick Jones
2020-11-17 16:40:37 -08:00
parent b1b1e51616
commit aa7010ab25
2 changed files with 26 additions and 19 deletions

View File

@@ -16,6 +16,10 @@ import (
"strings"
)
// ExchangeToken preforms a oauth2 token exchange with the provided endpoint.
// 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
// 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{}) (*STSTokenExchangeResponse, error) {
client := oauth2.NewClient(ctx, nil)
@@ -63,9 +67,11 @@ func ExchangeToken(ctx context.Context, endpoint string, request *STSTokenExchan
}
return &stsResp, nil
}
// STSTokenExchangeRequest contains fields necessary to make an oauth2 token exchange.
type STSTokenExchangeRequest struct {
ActingParty struct {
ActorToken string
@@ -80,6 +86,7 @@ type STSTokenExchangeRequest struct {
SubjectTokenType string
}
// STSTokenExchangeResponse is used to decode the remote server's response during an oauth2 token exchange.
type STSTokenExchangeResponse struct {
AccessToken string `json:"access_token"`
IssuedTokenType string `json:"issued_token_type"`