stack/apps/backend/src
Zai Shi f32921f17c
Making OAuth token refresh more robust (#767)
…oken validity handling in CRUD operations

<!--

Make sure you've read the CONTRIBUTING.md guidelines:
https://github.com/stack-auth/stack-auth/blob/dev/CONTRIBUTING.md

-->

<!-- ELLIPSIS_HIDDEN -->

----

> [!IMPORTANT]
> Enhances OAuth token handling by adding validity checks, marking
invalid tokens, and attempting token refreshes in `crud.tsx`.
> 
>   - **Behavior**:
> - Adds `isValid` column to `OAuthAccessToken` and `OAuthToken` in
`migration.sql` and `schema.prisma`.
> - In `crud.tsx`, filters tokens by `isValid` status and marks them
invalid if server-side checks fail.
> - Attempts to refresh tokens if no valid access token is found,
logging errors and marking refresh tokens invalid if refresh fails.
>   - **Error Handling**:
>     - Uses `captureError` to log token refresh errors in `crud.tsx`.
>   - **Misc**:
>     - Imports `TokenSet` and `captureError` in `crud.tsx`.
> 
> <sup>This description was created by </sup>[<img alt="Ellipsis"
src="https://img.shields.io/badge/Ellipsis-blue?color=175173">](https://www.ellipsis.dev?ref=stack-auth%2Fstack-auth&utm_source=github&utm_medium=referral)<sup>
for a45b64f98e. You can
[customize](https://app.ellipsis.dev/stack-auth/settings/summaries) this
summary. It will automatically update as commits are pushed.</sup>

<!-- ELLIPSIS_HIDDEN -->

---------

Co-authored-by: Konsti Wohlwend <n2d4xc@gmail.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
2025-07-16 23:00:22 +02:00
..
app Making OAuth token refresh more robust (#767) 2025-07-16 23:00:22 +02:00
lib Improve email sending error handling (#732) 2025-07-16 22:57:55 +02:00
oauth Source of Truth (#660) 2025-07-11 17:59:03 -07:00
route-handlers Source of Truth (#660) 2025-07-11 17:59:03 -07:00
utils Source of Truth (#660) 2025-07-11 17:59:03 -07:00
analytics.tsx Fix event capture 2024-08-14 12:49:35 -07:00
globals.d.ts Split backend and dashboard (#83) 2024-06-18 15:49:31 +02:00
instrumentation.ts Source of Truth (#660) 2025-07-11 17:59:03 -07:00
middleware.tsx Fix Apple OAuth (#669) 2025-05-13 18:38:09 +02:00
polyfills.tsx Fix unhandled promise rejections in rawQuery 2025-04-11 09:59:45 -07:00
prisma-client.tsx Source of Truth (#660) 2025-07-11 17:59:03 -07:00
smart-router.tsx Move /api/v1 to /api/latest 2025-02-05 17:24:43 -08:00