Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Requesting review from @JeanMeijer who has experience with the following files modified in this PR:
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
|
Tembo is working on fixing this failing workflow: |
| import { TRPCError } from "@trpc/server"; | ||
| import { eq } from "drizzle-orm"; | ||
|
|
||
| import { db } from "@repo/db"; | ||
| import { account } from "@repo/db/schema"; | ||
| import { env } from "@repo/env/server"; | ||
|
|
||
| interface GoogleTokenResponse { | ||
| access_token: string; | ||
| refresh_token?: string; | ||
| expires_in: number; | ||
| token_type: string; | ||
| } | ||
|
|
||
| interface MicrosoftTokenResponse { | ||
| access_token: string; | ||
| refresh_token?: string; | ||
| expires_in: number; | ||
| token_type: string; | ||
| } | ||
|
|
||
| interface RefreshTokenOptions { | ||
| refreshToken: string; | ||
| accountId: string; | ||
| } | ||
|
|
||
| export async function refreshGoogleAccessToken({ | ||
| refreshToken, | ||
| accountId, | ||
| }: RefreshTokenOptions): Promise<string> { | ||
| try { | ||
| const response = await fetch("https://oauth2.googleapis.com/token", { | ||
| method: "POST", | ||
| headers: { | ||
| "Content-Type": "application/x-www-form-urlencoded", | ||
| }, | ||
| body: new URLSearchParams({ | ||
| client_id: env.GOOGLE_CLIENT_ID, | ||
| client_secret: env.GOOGLE_CLIENT_SECRET, | ||
| refresh_token: refreshToken, |
There was a problem hiding this comment.
use better auth to refresh the tokens, instead of passing the accessToken to the provider pass enough info so we can refresh the token using better-auth
|
Thanks for the feedback about using Better Auth for token refreshing. I've refactored the token refresh implementation to leverage our auth service instead of directly managing OAuth tokens:
This approach is more secure and maintainable as the token refresh logic is now handled by the auth service rather than managed directly in our application. |
Description
Resolve Google Calendar authentication failures by implementing token refresh mechanism
Changes
refreshGoogleAccessTokenutility functionSummary by cubic
Automatically refreshes expired Google access tokens to stop calendar operations from failing, with a single retry after refresh and DB persistence of new tokens. Adds the same refresh flow for Microsoft Calendar.
Bug Fixes
Migration