@@ -39,7 +39,7 @@ export interface ConnectorConnectionResponse {
3939}
4040
4141/**
42- * Connectors module for managing OAuth tokens for external services.
42+ * Connectors module for managing app-scoped OAuth tokens for external services.
4343 *
4444 * This module allows you to retrieve OAuth access tokens for external services that the app has connected to. Connectors are app-scoped. When an app builder connects an integration like Google Calendar, Slack, or GitHub, all users of the app share that same connection.
4545 *
@@ -233,3 +233,76 @@ export interface ConnectorsModule {
233233 integrationType : ConnectorIntegrationType ,
234234 ) : Promise < ConnectorConnectionResponse > ;
235235}
236+
237+ /**
238+ * User-scoped connectors module for managing app-user OAuth connections.
239+ *
240+ * This module provides methods for app-user OAuth flows: initiating an OAuth connection,
241+ * retrieving the end user's access token, and disconnecting the end user's connection.
242+ *
243+ * Unlike {@link ConnectorsModule | ConnectorsModule} which manages app-scoped tokens,
244+ * this module manages tokens scoped to individual end users. Methods are keyed on
245+ * the connector ID (the OrgConnector's database ID) rather than the integration type.
246+ *
247+ * Available via `base44.connectors`.
248+ */
249+ export interface UserConnectorsModule {
250+ /**
251+ * Retrieves an OAuth access token for an end user's connection to a specific connector.
252+ *
253+ * Returns the OAuth token string that belongs to the currently authenticated end user
254+ * for the specified connector.
255+ *
256+ * @param connectorId - The connector ID (OrgConnector database ID).
257+ * @returns Promise resolving to the access token string.
258+ *
259+ * @example
260+ * ```typescript
261+ * // Get the end user's access token for a connector
262+ * const token = await base44.connectors.getCurrentAppUserAccessToken('abc123def');
263+ *
264+ * const response = await fetch('https://www.googleapis.com/calendar/v3/calendars/primary/events', {
265+ * headers: { 'Authorization': `Bearer ${token}` }
266+ * });
267+ * ```
268+ */
269+ getCurrentAppUserAccessToken ( connectorId : string ) : Promise < string > ;
270+
271+ /**
272+ * Initiates the app-user OAuth flow for a specific connector.
273+ *
274+ * Returns a redirect URL that the end user should be navigated to in order to
275+ * authenticate with the external service. The scopes and integration type are
276+ * derived from the connector configuration server-side.
277+ *
278+ * @param connectorId - The connector ID (OrgConnector database ID).
279+ * @returns Promise resolving to the redirect URL string.
280+ *
281+ * @example
282+ * ```typescript
283+ * // Start OAuth for the end user
284+ * const redirectUrl = await base44.connectors.connectAppUser('abc123def');
285+ *
286+ * // Redirect the user to the OAuth provider
287+ * window.location.href = redirectUrl;
288+ * ```
289+ */
290+ connectAppUser ( connectorId : string ) : Promise < string > ;
291+
292+ /**
293+ * Disconnects an end user's OAuth connection for a specific connector.
294+ *
295+ * Removes the stored OAuth credentials for the currently authenticated end user's
296+ * connection to the specified connector.
297+ *
298+ * @param connectorId - The connector ID (OrgConnector database ID).
299+ * @returns Promise resolving when the connection has been removed.
300+ *
301+ * @example
302+ * ```typescript
303+ * // Disconnect the end user's connection
304+ * await base44.connectors.disconnectAppUser('abc123def');
305+ * ```
306+ */
307+ disconnectAppUser ( connectorId : string ) : Promise < void > ;
308+ }
0 commit comments