Skip to main content

Connectors module for managing OAuth tokens for external services. 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 or Slack, all users of the app share that same connection. Unlike the integrations module that provides pre-built functions, connectors give you raw OAuth tokens so you can call external service APIs directly with full control over the API calls you make. This is useful when you need custom API interactions that aren’t covered by Base44’s pre-built integrations. This module is only available to use with a client in service role authentication mode, which means it can only be used in backend environments.

Methods

getAccessToken()

getAccessToken(integrationType): Promise<string>
Retrieves an OAuth access token for a specific external integration type. Returns the OAuth token string for an external service that an app builder has connected to. This token represents the connected app builder’s account and can be used to make authenticated API calls to that external service on behalf of the app.

Parameters

integrationType
string
required
The type of integration, such as 'googlecalendar', 'slack', or 'github'.

Returns

Promise<string> Promise resolving to the access token string.

Examples

// Get Google Calendar OAuth token and fetch upcoming events
const googleToken = await base44.asServiceRole.connectors.getAccessToken('googlecalendar');

// Fetch upcoming 10 events
const timeMin = new Date().toISOString();
const url = `https://www.googleapis.com/calendar/v3/calendars/primary/events?maxResults=10&orderBy=startTime&singleEvents=true&timeMin=${timeMin}`;

const calendarResponse = await fetch(url, {
  headers: { 'Authorization': `Bearer ${googleToken}` }
});

const events = await calendarResponse.json();