From 33bef6acd0055cc652658e0097147b982d144a1b Mon Sep 17 00:00:00 2001 From: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Date: Tue, 17 Oct 2023 07:27:10 -0400 Subject: [PATCH] Add conditional (#11862) --- packages/app-store/_utils/oauth/parseRefreshTokenResponse.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/app-store/_utils/oauth/parseRefreshTokenResponse.ts b/packages/app-store/_utils/oauth/parseRefreshTokenResponse.ts index 3b35588514..fc0d7fc21d 100644 --- a/packages/app-store/_utils/oauth/parseRefreshTokenResponse.ts +++ b/packages/app-store/_utils/oauth/parseRefreshTokenResponse.ts @@ -16,6 +16,8 @@ export type ParseRefreshTokenResponse = const parseRefreshTokenResponse = (response: any, schema: z.ZodTypeAny) => { let refreshTokenResponse; + const credentialSyncingEnabled = + APP_CREDENTIAL_SHARING_ENABLED && process.env.CALCOM_CREDENTIAL_SYNC_ENDPOINT; if (APP_CREDENTIAL_SHARING_ENABLED && process.env.CALCOM_CREDENTIAL_SYNC_ENDPOINT) { refreshTokenResponse = minimumTokenResponseSchema.safeParse(response); } else { @@ -26,7 +28,7 @@ const parseRefreshTokenResponse = (response: any, schema: z.ZodTypeAny) => { throw new Error("Invalid refreshed tokens were returned"); } - if (!refreshTokenResponse.data.refresh_token) { + if (!refreshTokenResponse.data.refresh_token && credentialSyncingEnabled) { refreshTokenResponse.data.refresh_token = "refresh_token"; }