Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
6bfe2f3
Update environment variable names: VECTORIZE_TOKEN → VECTORIZE_API_KE…
devin-ai-integration[bot] Jun 27, 2025
04f3daa
Restructure documentation with step-based organization
devin-ai-integration[bot] Jun 27, 2025
fdf13dc
Add specific usage examples for Google Drive, Dropbox, and Notion con…
devin-ai-integration[bot] Jun 27, 2025
9ad321f
Fix incorrect function names: replace createVectorizeConnector with p…
devin-ai-integration[bot] Jun 27, 2025
cd8b198
Merge remote-tracking branch 'origin/main' into devin/1751035441-upda…
devin-ai-integration[bot] Jun 27, 2025
12921c0
Update all Notion connector references to use correct platform-specif…
devin-ai-integration[bot] Jun 27, 2025
0555cb5
Add White Label Notion connector example to creating-connectors overview
devin-ai-integration[bot] Jun 27, 2025
c590cc5
Complete Notion connector documentation updates
devin-ai-integration[bot] Jun 27, 2025
53c16df
Move legacy platform-specific documentation to legacy-docs folder
devin-ai-integration[bot] Jun 27, 2025
19ce549
Add comprehensive authentication documentation for Google Drive, Drop…
devin-ai-integration[bot] Jun 27, 2025
43d5fdd
Add comprehensive platform-specific documentation for frontend implem…
devin-ai-integration[bot] Jun 27, 2025
02e3fe3
Complete comprehensive platform-specific documentation
devin-ai-integration[bot] Jun 27, 2025
1ef9a13
Complete comprehensive platform-specific documentation
devin-ai-integration[bot] Jun 27, 2025
97f6b30
Add missing authentication/white-label/README.md
devin-ai-integration[bot] Jun 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
220 changes: 210 additions & 10 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ This document provides a comprehensive reference for all functions and classes a
- [createWhiteLabelGDriveConnector](#createwhitelabelgdriveconnector)
- [createVectorizeDropboxConnector](#createvectorizedropboxconnector)
- [createWhiteLabelDropboxConnector](#createwhitelabeldropboxconnector)
- [createVectorizeNotionConnector](#createvectorizenotionconnector)
- [createWhiteLabelNotionConnector](#createwhitelabelnotionconnector)
- [Base API Functions](#base-api-functions)
- [createSourceConnector](#createsourceconnector)
- [manageUser](#manageuser)
Expand All @@ -24,6 +26,9 @@ This document provides a comprehensive reference for all functions and classes a
- [refreshGDriveToken](#refreshgdrivetoken)
- [exchangeDropboxCodeForTokens](#exchangedropboxcodefortokens)
- [refreshDropboxToken](#refreshdropboxtoken)
- [exchangeNotionCodeForTokens](#exchangenotioncodefortokens)
- [refreshNotionToken](#refreshnotiontoken)
- [manageNotionUser](#managenotionuser)

## OAuth Classes

Expand Down Expand Up @@ -351,8 +356,8 @@ async function createVectorizeGDriveConnector(
**Parameters:**

- `config`: A `VectorizeAPIConfig` object containing:
- `authorization`: Bearer token for authentication (use VECTORIZE_TOKEN env var)
- `organizationId`: Your Vectorize organization ID (use VECTORIZE_ORG env var)
- `authorization`: Bearer token for authentication (use VECTORIZE_API_KEY env var)
- `organizationId`: Your Vectorize organization ID (use VECTORIZE_ORGANIZATION_ID env var)
- `connectorName`: Name for the connector
- `platformUrl` (optional): URL of the Vectorize API (defaults to "https://api.vectorize.io/v1")

Expand All @@ -364,8 +369,8 @@ async function createVectorizeGDriveConnector(

```typescript
const config = {
authorization: process.env.VECTORIZE_TOKEN!,
organizationId: process.env.VECTORIZE_ORG!,
authorization: process.env.VECTORIZE_API_KEY!,
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
};

const connectorId = await createVectorizeGDriveConnector(
Expand Down Expand Up @@ -404,8 +409,8 @@ async function createWhiteLabelGDriveConnector(

```typescript
const config = {
authorization: process.env.VECTORIZE_TOKEN!,
organizationId: process.env.VECTORIZE_ORG!,
authorization: process.env.VECTORIZE_API_KEY!,
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
};

const connectorId = await createWhiteLabelGDriveConnector(
Expand Down Expand Up @@ -442,8 +447,8 @@ async function createVectorizeDropboxConnector(

```typescript
const config = {
authorization: process.env.VECTORIZE_TOKEN!,
organizationId: process.env.VECTORIZE_ORG!,
authorization: process.env.VECTORIZE_API_KEY!,
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
};

const connectorId = await createVectorizeDropboxConnector(
Expand Down Expand Up @@ -482,8 +487,8 @@ async function createWhiteLabelDropboxConnector(

```typescript
const config = {
authorization: process.env.VECTORIZE_TOKEN!,
organizationId: process.env.VECTORIZE_ORG!,
authorization: process.env.VECTORIZE_API_KEY!,
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
};

const connectorId = await createWhiteLabelDropboxConnector(
Expand All @@ -494,6 +499,140 @@ const connectorId = await createWhiteLabelDropboxConnector(
);
```

### createVectorizeNotionConnector

Creates a Notion connector using Vectorize's managed OAuth credentials.

```typescript
async function createVectorizeNotionConnector(
config: VectorizeAPIConfig,
connectorName: string,
platformUrl?: string
): Promise<string>
```

**Parameters:**

- `config`: A `VectorizeAPIConfig` object
- `connectorName`: Name for the connector
- `platformUrl` (optional): URL of the Vectorize API (defaults to "https://api.vectorize.io/v1")

**Returns:**

- `Promise<string>`: The ID of the created connector

**Example:**

```typescript
const config = {
authorization: process.env.VECTORIZE_API_KEY!,
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
};

const connectorId = await createVectorizeNotionConnector(
config,
"My Notion Connector"
);
```

### createWhiteLabelNotionConnector

Creates a Notion connector using your own OAuth credentials.

```typescript
async function createWhiteLabelNotionConnector(
config: VectorizeAPIConfig,
connectorName: string,
clientId: string,
clientSecret: string,
platformUrl?: string
): Promise<string>
```

**Parameters:**

- `config`: A `VectorizeAPIConfig` object
- `connectorName`: Name for the connector
- `clientId`: Your Notion OAuth client ID
- `clientSecret`: Your Notion OAuth client secret
- `platformUrl` (optional): URL of the Vectorize API (defaults to "https://api.vectorize.io/v1")

**Returns:**

- `Promise<string>`: The ID of the created connector

**Example:**

```typescript
const config = {
authorization: process.env.VECTORIZE_API_KEY!,
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
};

const connectorId = await createWhiteLabelNotionConnector(
config,
"My Custom Notion Connector",
process.env.NOTION_CLIENT_ID!,
process.env.NOTION_CLIENT_SECRET!
);
```

### manageNotionUser

Manages a Notion user for a connector, allowing you to add, edit, or remove users.

```typescript
async function manageNotionUser(
config: VectorizeAPIConfig,
connectorId: string,
selectedPages: Record<string, { title: string; pageId: string; parentType?: string }> | null,
accessToken: string,
userId: string,
action: UserAction,
platformUrl?: string
): Promise<Response>
```

**Parameters:**

- `config`: A `VectorizeAPIConfig` object
- `connectorId`: ID of the connector
- `selectedPages`: Record of selected pages with their metadata (required for add/edit actions)
- `accessToken`: Notion OAuth access token (required for add/edit actions)
- `userId`: User ID to manage
- `action`: Action to perform ("add", "edit", or "remove")
- `platformUrl` (optional): URL of the Vectorize API (defaults to "https://api.vectorize.io/v1")

**Returns:**

- `Promise<Response>`: The API response

**Example:**

```typescript
const config = {
authorization: process.env.VECTORIZE_API_KEY!,
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
};

const selectedPages = {
"page1": {
title: "My Page",
pageId: "page1",
parentType: "workspace"
}
};

const response = await manageNotionUser(
config,
"connector123",
selectedPages,
"notion_access_token",
"user123",
"add"
);
```

## Base API Functions

### createSourceConnector
Expand Down Expand Up @@ -653,6 +792,67 @@ console.log('New access token:', tokens.access_token);
console.log('Expires in:', tokens.expires_in, 'seconds');
```

### exchangeNotionCodeForTokens

Exchanges an authorization code for Notion OAuth tokens.

```typescript
async function exchangeNotionCodeForTokens(
code: string,
clientId: string,
clientSecret: string,
redirectUri: string
): Promise<any>
```

**Parameters:**

- `code`: Authorization code from Notion OAuth flow
- `clientId`: Notion OAuth client ID
- `clientSecret`: Notion OAuth client secret
- `redirectUri`: Redirect URI used in the OAuth flow

**Returns:**

- `Promise<any>`: Notion OAuth tokens

**Example:**

```typescript
import { exchangeNotionCodeForTokens } from '@vectorize-io/vectorize-connect';

const tokens = await exchangeNotionCodeForTokens(
authCode,
process.env.NOTION_CLIENT_ID!,
process.env.NOTION_CLIENT_SECRET!,
"https://yourapp.com/callback"
);
```

### refreshNotionToken

Validates an existing Notion access token by making an API request to Notion.

```typescript
async function refreshNotionToken(accessToken: string): Promise<any>
```

**Parameters:**

- `accessToken`: Notion access token to validate

**Returns:**

- `Promise<any>`: Validated token information

**Example:**

```typescript
import { refreshNotionToken } from '@vectorize-io/vectorize-connect';

const validatedToken = await refreshNotionToken("notion_access_token");
```

### exchangeDropboxCodeForTokens

Exchanges an authorization code for access and refresh tokens.
Expand Down
68 changes: 68 additions & 0 deletions docs/authentication/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# Authentication

This section covers authentication flows for different connector approaches.

## Approaches

- **[Vectorize](./vectorize/)** - Authentication using Vectorize's managed OAuth flow
- **[White-Label](./white-label/)** - Authentication using your own OAuth applications

## Overview

Authentication is the process of connecting users to their cloud storage accounts and obtaining the necessary permissions to access their files.

### Vectorize Approach
- Users are redirected to Vectorize's platform for authentication
- Vectorize handles the OAuth flow and token management
- Simplified implementation with consistent user experience

### White-Label Approach
- Users authenticate directly with your OAuth application
- Full control over the authentication experience
- Requires implementing OAuth callback handling

## Platform-Specific Guides

### Vectorize Approach
- [Google Drive Authentication](./vectorize/google-drive.md)
- [Dropbox Authentication](./vectorize/dropbox.md)
- [Notion Authentication](./vectorize/notion.md)

### White-Label Approach
- [Google Drive Authentication](./white-label/google-drive.md)
- [Dropbox Authentication](./white-label/dropbox.md)
- [Notion Authentication](./white-label/notion.md)

## Quick Reference

### Vectorize Authentication Flow
```typescript
import { getOneTimeConnectorToken, GoogleDriveOAuth } from '@vectorize-io/vectorize-connect';

// 1. Generate one-time token
const tokenResponse = await getOneTimeConnectorToken(config, userId, connectorId);

// 2. Redirect to Vectorize authentication (example with Google Drive)
await GoogleDriveOAuth.redirectToVectorizeConnect(
tokenResponse.token,
organizationId
);
```

### White-Label Authentication Flow
```typescript
import { GoogleDriveOAuth } from '@vectorize-io/vectorize-connect';

// Start OAuth flow in popup (example with Google Drive)
GoogleDriveOAuth.startOAuth({
clientId: process.env.GOOGLE_OAUTH_CLIENT_ID!,
clientSecret: process.env.GOOGLE_OAUTH_CLIENT_SECRET!,
redirectUri: `${window.location.origin}/api/oauth/callback`,
onSuccess: (response) => {
// Handle successful authentication
},
onError: (error) => {
// Handle authentication error
}
});
```
Loading