Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: fix access token response to use remaining seconds#39

Merged
appleboy merged 1 commit intomainfrom
feature-token
Feb 19, 2026
Merged

fix: fix access token response to use remaining seconds#39
appleboy merged 1 commit intomainfrom
feature-token

Conversation

@appleboy
Copy link
Member

  • Use the correct remaining seconds until token expiration instead of the expiration timestamp in the access token response

- Use the correct remaining seconds until token expiration instead of the expiration timestamp in the access token response

Signed-off-by: appleboy <[email protected]>
Copilot AI review requested due to automatic review settings February 19, 2026 10:24
@appleboy appleboy merged commit 4c1d3f6 into main Feb 19, 2026
19 checks passed
@appleboy appleboy deleted the feature-token branch February 19, 2026 10:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects the OAuth token endpoint’s expires_in field for the authorization code grant to return remaining lifetime (seconds) instead of an absolute Unix expiration timestamp, aligning the response with common OAuth client expectations.

Changes:

  • Update expires_in in the authorization code grant token response to use remaining seconds until ExpiresAt.
  • Add time import to support the new calculation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 335 to 339
resp := gin.H{
"access_token": accessToken.Token,
"token_type": accessToken.TokenType,
"expires_in": int(accessToken.ExpiresAt.Unix()),
"expires_in": int(time.Until(accessToken.ExpiresAt).Seconds()),
"scope": accessToken.Scopes,
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expires_in is derived via int(time.Until(accessToken.ExpiresAt).Seconds()), which converts through float seconds (truncation/precision) and can produce a negative value if ExpiresAt is already in the past (e.g., provider clock skew or misconfigured expiry). Consider computing remaining seconds using integer duration math (e.g., duration / time.Second) and clamping to a minimum of 0 to keep the OAuth expires_in field non-negative and stable.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants