@@ -22,6 +22,18 @@ export type ConnectorIntegrationType = keyof ConnectorIntegrationTypeRegistry ex
2222 */
2323export interface ConnectorAccessTokenResponse {
2424 access_token : string ;
25+ integration_type : string ;
26+ connection_config : Record < string , string > | null ;
27+ }
28+
29+ /**
30+ * Camel-cased connection details returned by {@linkcode ConnectorsModule.getConnection | getConnection()}.
31+ */
32+ export interface ConnectorConnectionResponse {
33+ /** The OAuth access token for the external service. */
34+ accessToken : string ;
35+ /** Key-value configuration for the connection, or `null` if the connector does not provide one. */
36+ connectionConfig : Record < string , string > | null ;
2537}
2638
2739/**
@@ -87,4 +99,36 @@ export interface ConnectorsModule {
8799 * ```
88100 */
89101 getAccessToken ( integrationType : ConnectorIntegrationType ) : Promise < string > ;
102+
103+ /**
104+ * Retrieves the OAuth access token and connection configuration for a specific external integration type.
105+ *
106+ * Returns both the OAuth token and any additional connection configuration
107+ * that the connector provides. This is useful when the external service requires
108+ * extra parameters beyond the access token (e.g., a shop domain, account ID, or API base URL).
109+ *
110+ * @param integrationType - The type of integration, such as `'googlecalendar'`, `'slack'`, or `'github'`.
111+ * @returns Promise resolving to a {@link ConnectorConnectionResponse} with `accessToken` and `connectionConfig`.
112+ *
113+ * @example
114+ * ```typescript
115+ * // Basic usage
116+ * const connection = await base44.asServiceRole.connectors.getConnection('googlecalendar');
117+ * console.log(connection.accessToken);
118+ * console.log(connection.connectionConfig);
119+ * ```
120+ *
121+ * @example
122+ * ```typescript
123+ * // Using connection config for a service that requires extra parameters
124+ * const connection = await base44.asServiceRole.connectors.getConnection('shopify');
125+ * const { accessToken, connectionConfig } = connection;
126+ *
127+ * const response = await fetch(
128+ * `https://${connectionConfig?.shop}/admin/api/2024-01/products.json`,
129+ * { headers: { 'X-Shopify-Access-Token': accessToken } }
130+ * );
131+ * ```
132+ */
133+ getConnection ( integrationType : ConnectorIntegrationType ) : Promise < ConnectorConnectionResponse > ;
90134}
0 commit comments