Skip to content

OAuth credential sync and app integration enhancements - #4

Open
akshayutture-augment wants to merge 1 commit into
oauth-security-basefrom
oauth-security-enhanced
Open

OAuth credential sync and app integration enhancements#4
akshayutture-augment wants to merge 1 commit into
oauth-security-basefrom
oauth-security-enhanced

Conversation

@akshayutture-augment

@akshayutture-augment akshayutture-augment commented Nov 14, 2025

Copy link
Copy Markdown

Test 8


Replicated from ai-code-review-evaluation/cal.com-cursor#8


Note

Introduces an app-credential sync webhook and shared OAuth refresh utilities, updating many integrations to use them and adding required env/config flags.

  • API/Webhook
    • Add apps/web/pages/api/webhook/app-credential.ts to sync app credentials via verified webhook (decrypts keys, creates/updates prisma.credential).
  • OAuth Utilities
    • New helpers: parseRefreshTokenResponse and refreshOAuthTokens under packages/app-store/_utils/oauth/.
    • Move encodeOAuthState/decodeOAuthState and createOAuthAppCredential into .../_utils/oauth/ and update imports.
  • Integrations (token refresh refactor)
    • Update Google Calendar, HubSpot, Lark Calendar, Office365 Calendar, MS Teams (video), Webex, Zoom, Zoho Bigin, Zoho CRM, and Salesforce to use centralized refresh flow and/or relaxed token parsing when credential sharing is enabled.
    • Salesforce: refresh token on client init and persist updated credentials.
    • Zoho Bigin: fix redirect_uri in add flow.
  • Config/Env
    • .env.example: add App Credential Sync settings (CALCOM_WEBHOOK_SECRET, CALCOM_WEBHOOK_HEADER_NAME, CALCOM_CREDENTIAL_SYNC_ENDPOINT, CALCOM_APP_CREDENTIAL_ENCRYPTION_KEY).
    • packages/lib/constants.ts: add APP_CREDENTIAL_SHARING_ENABLED flag.
    • turbo.json: expose new env vars in globalEnv.

Written by Cursor Bugbot for commit 824145b. Configure here.

…11059)

* Add credential sync .env variables

* Add webhook to send app credentials

* Upsert credentials when webhook called

* Refresh oauth token from a specific endpoint

* Pass appSlug

* Add credential encryption

* Move oauth helps into a folder

* Create parse token response wrapper

* Add OAuth helpers to apps

* Clean up

* Refactor `appDirName` to `appSlug`

* Address feedback

* Change to safe parse

* Remove console.log

---------

Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com>
Co-authored-by: Omar López <zomars@me.com>

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

googleCredentials.access_token = token.access_token;
googleCredentials.expiry_date = token.expiry_date;
const key = googleCredentialSchema.parse(googleCredentials);
const key = parseRefreshTokenResponse(googleCredentials, googleCredentialSchema);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Storing the Wrapper, Not the Data

parseRefreshTokenResponse returns a SafeParseReturnType object with success and data properties, but the code treats it as the actual token data. The Prisma update stores the entire { success, data } object instead of just the validated token data. Should use key.data when updating the credential.

Fix in Cursor Fix in Web

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