Skip to content

Commit ee65555

Browse files
committed
Rearrange placement of logging ID Token payload. Print all claims on ID token
1 parent 0f0c70a commit ee65555

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

internal/command/client.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -158,19 +158,11 @@ func (g *gcp) GetAccessToken(ctx context.Context) (string, error) {
158158
return "", fmt.Errorf("%w: failed to get GCP ID Token Source: %w", errTokenFetchFailure, err)
159159
}
160160

161-
token, err := tokenSource.Token()
161+
_, err = tokenSource.Token()
162162
if err != nil {
163163
return "", fmt.Errorf("%w: failed to generate GCP JWT Token from token source: %w", errTokenFetchFailure, err)
164164
}
165165

166-
log.Info(fmt.Sprintf("Google OIDC ID token successfully generated."))
167-
168-
payload, _ := idtoken.ParsePayload(token.AccessToken)
169-
170-
prettyPayload, _ := json.MarshalIndent(payload, "", " ")
171-
172-
log.Info(fmt.Sprintf("Google OIDC ID token payload: %s", prettyPayload))
173-
174166
g.tokenSource = tokenSource
175167
}
176168

@@ -181,6 +173,13 @@ func (g *gcp) GetAccessToken(ctx context.Context) (string, error) {
181173
}
182174

183175
log.Info("fetched token using GCP ApplicationDefaultCredential")
176+
177+
payload, _ := idtoken.ParsePayload(token.AccessToken)
178+
179+
prettyPayload, _ := json.MarshalIndent(payload.Claims, "", " ")
180+
181+
log.Info(fmt.Sprintf("Google OIDC ID token payload: %s", prettyPayload))
182+
184183
return token.AccessToken, nil
185184
}
186185

0 commit comments

Comments
 (0)