Files
Peter EvansandJeremie Pardou e4b9a2615b feat: add a shared base for integrations that connect an account through OAuth (#6810)
* feat: add a shared base for integrations that connect an account through OAuth

* fix: keep OAuth account scopes current and bound provider answers

* fix: share parent registration between form APIs

* fix: preserve refreshed OAuth tokens when actions fail

* refactor: use absolute imports for parent OAuth modules

* refactor: decouple OAuth cleanup from application publication models

* refactor: use common import hooks for OAuth connections

* fix: keep OAuth account integrations out of the workspace

---------

Co-authored-by: Jeremie Pardou <571533+jrmi@users.noreply.github.com>
2026-11-30 08:55:52 +00:00

28 lines
1.2 KiB
JavaScript

import { OAUTH_ERROR_CODE } from '@baserow/modules/integrations/oauthAccount/constants'
const MESSAGES = {
[OAUTH_ERROR_CODE.NOT_CONFIGURED]: 'oauthAccountErrors.notConfigured',
[OAUTH_ERROR_CODE.STATE_INVALID]: 'oauthAccountErrors.stateInvalid',
[OAUTH_ERROR_CODE.SIGN_IN_CANCELLED]: 'oauthAccountErrors.cancelled',
[OAUTH_ERROR_CODE.ADMIN_CONSENT_REQUIRED]:
'oauthAccountErrors.adminConsentRequired',
[OAUTH_ERROR_CODE.TENANT_NOT_ALLOWED]: 'oauthAccountErrors.tenantNotAllowed',
[OAUTH_ERROR_CODE.CLIENT_REJECTED]: 'oauthAccountErrors.clientRejected',
[OAUTH_ERROR_CODE.ACCOUNT_MISMATCH]: 'oauthAccountErrors.accountMismatch',
[OAUTH_ERROR_CODE.SERVICE_TYPE_NOT_ALLOWED]:
'oauthAccountErrors.serviceTypeNotAllowed',
[OAUTH_ERROR_CODE.POPUP_BLOCKED]: 'oauthAccountErrors.popupBlocked',
}
/**
* What to tell the person when a sign-in failed.
*
* @param {Function} t The translate function.
* @param {string|null} code The API error code, null when none came back.
* @param {string} provider The provider's name, e.g. `Microsoft`.
* @returns {string}
*/
export function oauthErrorMessage(t, code, provider) {
return t(MESSAGES[code] || 'oauthAccountErrors.failed', { provider })
}