Skip to content

Commit

Permalink
Merge pull request #7 from pingidentity/ImproveTokenErrorMessaging
Browse files Browse the repository at this point in the history
Add body info to token error messages
  • Loading branch information
henryrecker-pingidentity authored Nov 18, 2024
2 parents 3c9f0a3 + 44632f7 commit daaf909
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion identitycloud/access_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,14 @@ func (s ServiceAccountTokenSource) Token() (*oauth2.Token, error) {
if err != nil {
return nil, fmt.Errorf("failed to read access token response body: %w", err)
}
if httpResp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("failed to request access token with service account. Status code: %d, body: %s", httpResp.StatusCode, body)
}

var token oauth2.Token
err = json.Unmarshal(body, &token)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal access token response: %w", err)
return nil, fmt.Errorf("failed to unmarshal access token response: %w, body: %s", err, body)
}

token.Expiry = time.Now().Add(time.Duration(token.ExpiresIn) * time.Second)
Expand Down

0 comments on commit daaf909

Please sign in to comment.