Skip to content

Commit

Permalink
naming: defaultidtoken
Browse files Browse the repository at this point in the history
  • Loading branch information
thepwagner committed Dec 21, 2021
1 parent fccf45c commit 2e2e7d5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions v2/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ func WithIDTokenAuth() Option {
}
}

// WithDefaultTokenAuth configures the client to use Google's default token.
func WithDefaultTokenAuth() Option {
// WithDefaultIDTokenAuth configures the client to use Google's default token.
func WithDefaultIDTokenAuth() Option {
return func(ctx context.Context, c *Client) error {
src, err := google.DefaultTokenSource(ctx)
if err != nil {
return fmt.Errorf("error getting default token source: %w", err)
}
ts := oauth2.ReuseTokenSource(nil, &idTokenSource{TokenSource: src, audience: c.url.String()})
ts := oauth2.ReuseTokenSource(nil, &defaultIDTokenSource{TokenSource: src, audience: c.url.String()})

transport, err := httptransport.NewTransport(ctx, http.DefaultTransport, option.WithTokenSource(ts))
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions v2/client/idtoken.go → v2/client/defaultidtoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"google.golang.org/api/option"
)

// idTokenSource is an oauth2.TokenSource that wraps another
// defaultIDTokenSource is an oauth2.TokenSource that wraps another
// It takes the id_token from TokenSource and passes that on as a bearer token
// Implementation from: https://github.com/googleapis/google-api-go-client/issues/873
type idTokenSource struct {
type defaultIDTokenSource struct {
TokenSource oauth2.TokenSource
audience string
}

func (s *idTokenSource) Token() (*oauth2.Token, error) {
func (s *defaultIDTokenSource) Token() (*oauth2.Token, error) {
tok, err := s.TokenSource.Token()
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion v2/cmd/voucher_client/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func getVoucherClient() (voucher.Interface, error) {
case "idtoken":
options = append(options, client.WithIDTokenAuth())
case "default-access-token":
options = append(options, client.WithDefaultTokenAuth())
options = append(options, client.WithDefaultIDTokenAuth())
default:
return nil, fmt.Errorf("invalid auth value: %q", defaultConfig.Auth)
}
Expand Down

0 comments on commit 2e2e7d5

Please sign in to comment.