Creating Plot Twists
    Preparing search index...

    Class IntegrationsAbstract

    Built-in tool for managing OAuth authentication flows.

    The Integrations tool provides a unified interface for requesting user authorization from external service providers like Google and Microsoft. It handles the OAuth flow creation, token management, and callback integration.

    class CalendarTool extends Tool {
    private auth: Integrations;

    constructor(id: string, tools: ToolBuilder) {
    super();
    this.integrations = tools.get(Integrations);
    }

    async requestAuth() {
    return await this.integrations.request({
    provider: AuthProvider.Google,
    level: AuthLevel.User,
    scopes: ["https://www.googleapis.com/auth/calendar.readonly"]
    }, {
    functionName: "onAuthComplete",
    context: { provider: "google" }
    });
    }

    async onAuthComplete(authResult: Authorization, context: any) {
    const authToken = await this.integrations.get(authResult);
    }
    }

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Initiates an OAuth authentication flow.

      Creates an authentication link that users can click to authorize access to the specified provider with the requested scopes. When authorization completes, the callback will be invoked with the Authorization and any extraArgs.

      Type Parameters

      Parameters

      • auth: { provider: AuthProvider; level: AuthLevel; scopes: string[] }

        Authentication configuration

        • provider: AuthProvider

          The OAuth provider to authenticate with

        • level: AuthLevel

          The authorization level (priority-scoped or user-scoped)

        • scopes: string[]

          Array of OAuth scopes to request

      • callback: TCallback

        Function receiving (authorization, ...extraArgs)

      • ...extraArgs: TCallback extends (auth: any, ...rest: R) => any ? NoFunctions<R> : []

        Additional arguments to pass to the callback (type-checked, must be serializable)

      Returns Promise<ActivityLink>

      Promise resolving to an ActivityLink for the auth flow

    • Retrieves an access token (refreshing it first if necessary).

      Returns null if the authorization is no longer valid or has been revoked.

      Parameters

      • authorization: Authorization

        The authorization from the request callback

      Returns Promise<AuthToken | null>

      Promise resolving to the access token or null if no longer available