Capture absolute expiresAt on AccessToken - #25
Merged
Conversation
Add `expiresAt: Instant` to `AccessToken` alongside the existing `expiresIn: ExpiresIn` and fix the deadline at fetch time. The http4s entity decoder reads the wire-format `(access_token, expires_in)` response (now also accepting `id_token` via an `.or` alternative) and computes `expiresAt = now + expires_in` via `Clock`. The `GcpLoginCallbackHandler` Kafka envelope now reads `token.expiresAt.getEpochSecond` directly, eliminating the `now + cached expiresIn` drift that previously overstated the broker-visible deadline by up to the cache safety period. `identity` and `userIdentity` factories pass `expiresAt` through; `userIdentity(triple)` shrinks to a single `httpClient.expect[AccessToken]` call now that the entity decoder handles both `access_token` and `id_token` shapes. `safetyPeriod` is unchanged. Tests using `AccessToken` equality switch to a token-only assertion (Approach 1) to avoid having to fabricate matching `expiresAt` instants.
alejandrohdezma
force-pushed
the
bug/expires-at
branch
from
May 26, 2026 11:10
b2a9d7d to
3ff6c2a
Compare
Oliver-Taylor
approved these changes
Jun 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🚀 What's included in this PR?
Adds an
expiresAt: Instantfield toAccessTokenalongside the existingexpiresIn: ExpiresInand fixes the absolute deadline at fetch time. The http4s entity decoder reads the wire-format(access_token, expires_in)response (also acceptingid_tokenvia an.oralternative) and computesexpiresAt = now + expires_inviaClock.This eliminates a subtle drift bug: callers that cached an
AccessTokenand later computednow + token.expiresInended up overstating the deadline by however long the token had been cached. Readingtoken.expiresAtdirectly gives the fetch-time-fixed deadline.identityanduserIdentityfactories now threadexpiresAtthrough.userIdentity(triple)collapses to a singlehttpClient.expect[AccessToken]call since the entity decoder handles bothaccess_tokenandid_tokenresponse shapes.safetyPeriodis unchanged.Test assertions that compared full
AccessTokeninstances were loosened to compare only theTokenvalue (Approach 1) so they don't have to fabricate matchingInstants.