Skip to content

Commit e1810fa

Browse files
authored
Merge pull request #19 from vectorize-io/devin/1751035441-update-env-var-names
2 parents e23c3d2 + 97f6b30 commit e1810fa

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+11547
-55
lines changed

docs/API.md

Lines changed: 210 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ This document provides a comprehensive reference for all functions and classes a
1515
- [createWhiteLabelGDriveConnector](#createwhitelabelgdriveconnector)
1616
- [createVectorizeDropboxConnector](#createvectorizedropboxconnector)
1717
- [createWhiteLabelDropboxConnector](#createwhitelabeldropboxconnector)
18+
- [createVectorizeNotionConnector](#createvectorizenotionconnector)
19+
- [createWhiteLabelNotionConnector](#createwhitelabelnotionconnector)
1820
- [Base API Functions](#base-api-functions)
1921
- [createSourceConnector](#createsourceconnector)
2022
- [manageUser](#manageuser)
@@ -24,6 +26,9 @@ This document provides a comprehensive reference for all functions and classes a
2426
- [refreshGDriveToken](#refreshgdrivetoken)
2527
- [exchangeDropboxCodeForTokens](#exchangedropboxcodefortokens)
2628
- [refreshDropboxToken](#refreshdropboxtoken)
29+
- [exchangeNotionCodeForTokens](#exchangenotioncodefortokens)
30+
- [refreshNotionToken](#refreshnotiontoken)
31+
- [manageNotionUser](#managenotionuser)
2732

2833
## OAuth Classes
2934

@@ -351,8 +356,8 @@ async function createVectorizeGDriveConnector(
351356
**Parameters:**
352357

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

@@ -364,8 +369,8 @@ async function createVectorizeGDriveConnector(
364369

365370
```typescript
366371
const config = {
367-
authorization: process.env.VECTORIZE_TOKEN!,
368-
organizationId: process.env.VECTORIZE_ORG!,
372+
authorization: process.env.VECTORIZE_API_KEY!,
373+
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
369374
};
370375
371376
const connectorId = await createVectorizeGDriveConnector(
@@ -404,8 +409,8 @@ async function createWhiteLabelGDriveConnector(
404409

405410
```typescript
406411
const config = {
407-
authorization: process.env.VECTORIZE_TOKEN!,
408-
organizationId: process.env.VECTORIZE_ORG!,
412+
authorization: process.env.VECTORIZE_API_KEY!,
413+
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
409414
};
410415
411416
const connectorId = await createWhiteLabelGDriveConnector(
@@ -442,8 +447,8 @@ async function createVectorizeDropboxConnector(
442447

443448
```typescript
444449
const config = {
445-
authorization: process.env.VECTORIZE_TOKEN!,
446-
organizationId: process.env.VECTORIZE_ORG!,
450+
authorization: process.env.VECTORIZE_API_KEY!,
451+
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
447452
};
448453
449454
const connectorId = await createVectorizeDropboxConnector(
@@ -482,8 +487,8 @@ async function createWhiteLabelDropboxConnector(
482487

483488
```typescript
484489
const config = {
485-
authorization: process.env.VECTORIZE_TOKEN!,
486-
organizationId: process.env.VECTORIZE_ORG!,
490+
authorization: process.env.VECTORIZE_API_KEY!,
491+
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
487492
};
488493
489494
const connectorId = await createWhiteLabelDropboxConnector(
@@ -494,6 +499,140 @@ const connectorId = await createWhiteLabelDropboxConnector(
494499
);
495500
```
496501

502+
### createVectorizeNotionConnector
503+
504+
Creates a Notion connector using Vectorize's managed OAuth credentials.
505+
506+
```typescript
507+
async function createVectorizeNotionConnector(
508+
config: VectorizeAPIConfig,
509+
connectorName: string,
510+
platformUrl?: string
511+
): Promise<string>
512+
```
513+
514+
**Parameters:**
515+
516+
- `config`: A `VectorizeAPIConfig` object
517+
- `connectorName`: Name for the connector
518+
- `platformUrl` (optional): URL of the Vectorize API (defaults to "https://api.vectorize.io/v1")
519+
520+
**Returns:**
521+
522+
- `Promise<string>`: The ID of the created connector
523+
524+
**Example:**
525+
526+
```typescript
527+
const config = {
528+
authorization: process.env.VECTORIZE_API_KEY!,
529+
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
530+
};
531+
532+
const connectorId = await createVectorizeNotionConnector(
533+
config,
534+
"My Notion Connector"
535+
);
536+
```
537+
538+
### createWhiteLabelNotionConnector
539+
540+
Creates a Notion connector using your own OAuth credentials.
541+
542+
```typescript
543+
async function createWhiteLabelNotionConnector(
544+
config: VectorizeAPIConfig,
545+
connectorName: string,
546+
clientId: string,
547+
clientSecret: string,
548+
platformUrl?: string
549+
): Promise<string>
550+
```
551+
552+
**Parameters:**
553+
554+
- `config`: A `VectorizeAPIConfig` object
555+
- `connectorName`: Name for the connector
556+
- `clientId`: Your Notion OAuth client ID
557+
- `clientSecret`: Your Notion OAuth client secret
558+
- `platformUrl` (optional): URL of the Vectorize API (defaults to "https://api.vectorize.io/v1")
559+
560+
**Returns:**
561+
562+
- `Promise<string>`: The ID of the created connector
563+
564+
**Example:**
565+
566+
```typescript
567+
const config = {
568+
authorization: process.env.VECTORIZE_API_KEY!,
569+
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
570+
};
571+
572+
const connectorId = await createWhiteLabelNotionConnector(
573+
config,
574+
"My Custom Notion Connector",
575+
process.env.NOTION_CLIENT_ID!,
576+
process.env.NOTION_CLIENT_SECRET!
577+
);
578+
```
579+
580+
### manageNotionUser
581+
582+
Manages a Notion user for a connector, allowing you to add, edit, or remove users.
583+
584+
```typescript
585+
async function manageNotionUser(
586+
config: VectorizeAPIConfig,
587+
connectorId: string,
588+
selectedPages: Record<string, { title: string; pageId: string; parentType?: string }> | null,
589+
accessToken: string,
590+
userId: string,
591+
action: UserAction,
592+
platformUrl?: string
593+
): Promise<Response>
594+
```
595+
596+
**Parameters:**
597+
598+
- `config`: A `VectorizeAPIConfig` object
599+
- `connectorId`: ID of the connector
600+
- `selectedPages`: Record of selected pages with their metadata (required for add/edit actions)
601+
- `accessToken`: Notion OAuth access token (required for add/edit actions)
602+
- `userId`: User ID to manage
603+
- `action`: Action to perform ("add", "edit", or "remove")
604+
- `platformUrl` (optional): URL of the Vectorize API (defaults to "https://api.vectorize.io/v1")
605+
606+
**Returns:**
607+
608+
- `Promise<Response>`: The API response
609+
610+
**Example:**
611+
612+
```typescript
613+
const config = {
614+
authorization: process.env.VECTORIZE_API_KEY!,
615+
organizationId: process.env.VECTORIZE_ORGANIZATION_ID!,
616+
};
617+
618+
const selectedPages = {
619+
"page1": {
620+
title: "My Page",
621+
pageId: "page1",
622+
parentType: "workspace"
623+
}
624+
};
625+
626+
const response = await manageNotionUser(
627+
config,
628+
"connector123",
629+
selectedPages,
630+
"notion_access_token",
631+
"user123",
632+
"add"
633+
);
634+
```
635+
497636
## Base API Functions
498637

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

795+
### exchangeNotionCodeForTokens
796+
797+
Exchanges an authorization code for Notion OAuth tokens.
798+
799+
```typescript
800+
async function exchangeNotionCodeForTokens(
801+
code: string,
802+
clientId: string,
803+
clientSecret: string,
804+
redirectUri: string
805+
): Promise<any>
806+
```
807+
808+
**Parameters:**
809+
810+
- `code`: Authorization code from Notion OAuth flow
811+
- `clientId`: Notion OAuth client ID
812+
- `clientSecret`: Notion OAuth client secret
813+
- `redirectUri`: Redirect URI used in the OAuth flow
814+
815+
**Returns:**
816+
817+
- `Promise<any>`: Notion OAuth tokens
818+
819+
**Example:**
820+
821+
```typescript
822+
import { exchangeNotionCodeForTokens } from '@vectorize-io/vectorize-connect';
823+
824+
const tokens = await exchangeNotionCodeForTokens(
825+
authCode,
826+
process.env.NOTION_CLIENT_ID!,
827+
process.env.NOTION_CLIENT_SECRET!,
828+
"https://yourapp.com/callback"
829+
);
830+
```
831+
832+
### refreshNotionToken
833+
834+
Validates an existing Notion access token by making an API request to Notion.
835+
836+
```typescript
837+
async function refreshNotionToken(accessToken: string): Promise<any>
838+
```
839+
840+
**Parameters:**
841+
842+
- `accessToken`: Notion access token to validate
843+
844+
**Returns:**
845+
846+
- `Promise<any>`: Validated token information
847+
848+
**Example:**
849+
850+
```typescript
851+
import { refreshNotionToken } from '@vectorize-io/vectorize-connect';
852+
853+
const validatedToken = await refreshNotionToken("notion_access_token");
854+
```
855+
656856
### exchangeDropboxCodeForTokens
657857

658858
Exchanges an authorization code for access and refresh tokens.

docs/authentication/README.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Authentication
2+
3+
This section covers authentication flows for different connector approaches.
4+
5+
## Approaches
6+
7+
- **[Vectorize](./vectorize/)** - Authentication using Vectorize's managed OAuth flow
8+
- **[White-Label](./white-label/)** - Authentication using your own OAuth applications
9+
10+
## Overview
11+
12+
Authentication is the process of connecting users to their cloud storage accounts and obtaining the necessary permissions to access their files.
13+
14+
### Vectorize Approach
15+
- Users are redirected to Vectorize's platform for authentication
16+
- Vectorize handles the OAuth flow and token management
17+
- Simplified implementation with consistent user experience
18+
19+
### White-Label Approach
20+
- Users authenticate directly with your OAuth application
21+
- Full control over the authentication experience
22+
- Requires implementing OAuth callback handling
23+
24+
## Platform-Specific Guides
25+
26+
### Vectorize Approach
27+
- [Google Drive Authentication](./vectorize/google-drive.md)
28+
- [Dropbox Authentication](./vectorize/dropbox.md)
29+
- [Notion Authentication](./vectorize/notion.md)
30+
31+
### White-Label Approach
32+
- [Google Drive Authentication](./white-label/google-drive.md)
33+
- [Dropbox Authentication](./white-label/dropbox.md)
34+
- [Notion Authentication](./white-label/notion.md)
35+
36+
## Quick Reference
37+
38+
### Vectorize Authentication Flow
39+
```typescript
40+
import { getOneTimeConnectorToken, GoogleDriveOAuth } from '@vectorize-io/vectorize-connect';
41+
42+
// 1. Generate one-time token
43+
const tokenResponse = await getOneTimeConnectorToken(config, userId, connectorId);
44+
45+
// 2. Redirect to Vectorize authentication (example with Google Drive)
46+
await GoogleDriveOAuth.redirectToVectorizeConnect(
47+
tokenResponse.token,
48+
organizationId
49+
);
50+
```
51+
52+
### White-Label Authentication Flow
53+
```typescript
54+
import { GoogleDriveOAuth } from '@vectorize-io/vectorize-connect';
55+
56+
// Start OAuth flow in popup (example with Google Drive)
57+
GoogleDriveOAuth.startOAuth({
58+
clientId: process.env.GOOGLE_OAUTH_CLIENT_ID!,
59+
clientSecret: process.env.GOOGLE_OAUTH_CLIENT_SECRET!,
60+
redirectUri: `${window.location.origin}/api/oauth/callback`,
61+
onSuccess: (response) => {
62+
// Handle successful authentication
63+
},
64+
onError: (error) => {
65+
// Handle authentication error
66+
}
67+
});
68+
```

0 commit comments

Comments
 (0)