aboutsummaryrefslogtreecommitdiff
path: root/apps/docs/memory-api/connectors/advanced/bring-your-own-key.mdx
blob: 3d63cb4633c201fc8796afd1d0e7106322b002b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
---
title: 'Bring Your Own Key (BYOK)'
description: 'Configure your own OAuth application credentials for enhanced security and control'
---

By default, supermemory uses its own OAuth applications to connect to third-party providers. However, you can configure your own OAuth application credentials for enhanced security and control. This is particularly useful for enterprise customers who want to maintain control over their data access.

<Danger>
  Some providers like Google Drive require extensive verification and approval before you can use custom keys.
</Danger>

### Setting up Custom Provider Keys

To configure custom OAuth credentials for your organization, use the `PATCH /v3/settings` endpoint:

1. Set up your OAuth application on the provider's developer console.

Google: https://console.developers.google.com/apis/credentials/oauthclient \
Notion: https://www.notion.so/my-integrations \
OneDrive: https://portal.azure.com/#view/Microsoft_AAD_RegisteredApps/ApplicationsMenu 

2. If using Google drive, 

- Select the application type as `Web application`
- **Enable the Google drive api in "APIs and Services" in the Cloud Console**

3. Configure the redirect URL, set it to:

```
https://api.supermemory.ai/v3/connections/auth/callback/{provider}
```

For example, if you are using Google Drive, the redirect URL would be:

```
https://api.supermemory.ai/v3/connections/auth/callback/google-drive
```

4. Configure the client ID and client secret in the `PATCH /v3/settings` endpoint.

<CodeGroup>
```typescript Typescript
import Supermemory from 'supermemory';

const client = new Supermemory({
  apiKey: process.env['SUPERMEMORY_API_KEY'],
});

// Example: Configure Google Drive custom OAuth credentials
const settings = await client.settings.update({
  googleCustomKeyEnabled: true,
  googleDriveClientId: "your-google-client-id",
  googleDriveClientSecret: "your-google-client-secret"
});

// Example: Configure Notion custom OAuth credentials
const settings = await client.settings.update({
  notionCustomKeyEnabled: true,
  notionClientId: "your-notion-client-id",
  notionClientSecret: "your-notion-client-secret"
});

// Example: Configure OneDrive custom OAuth credentials
const settings = await client.settings.update({
  onedriveCustomKeyEnabled: true,
  onedriveClientId: "your-onedrive-client-id",
  onedriveClientSecret: "your-onedrive-client-secret"
});
```

```python Python
from supermemory import supermemory

client = supermemory(
    api_key=os.environ.get("SUPERMEMORY_API_KEY"),  # This is the default and can be omitted
)

# Example: Configure Google Drive custom OAuth credentials
settings = client.settings.update(
    google_custom_key_enabled=True,
    google_client_id="your-google-client-id",
    google_client_secret="your-google-client-secret"
)

# Example: Configure Notion custom OAuth credentials
settings = client.settings.update(
    notion_custom_key_enabled=True,
    notion_client_id="your-notion-client-id",
    notion_client_secret="your-notion-client-secret"
)

# Example: Configure OneDrive custom OAuth credentials
settings = client.settings.update(
    onedrive_custom_key_enabled=True,
    onedrive_client_id="your-onedrive-client-id",
    onedrive_client_secret="your-onedrive-client-secret"
)
```

```bash cURL
# Example: Configure Google Drive custom OAuth credentials
curl --request PATCH \
  --url https://api.supermemory.ai/v3/settings \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "googleDriveCustomKeyEnabled": true,
  "googleDriveClientId": "your-google-client-id",
  "googleDriveClientSecret": "your-google-client-secret"
}'

# Example: Configure Notion custom OAuth credentials
curl --request PATCH \
  --url https://api.supermemory.ai/v3/settings \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "notionCustomKeyEnabled": true,
  "notionClientId": "your-notion-client-id",
  "notionClientSecret": "your-notion-client-secret"
}'

# Example: Configure OneDrive custom OAuth credentials
curl --request PATCH \
  --url https://api.supermemory.ai/v3/settings \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "onedriveCustomKeyEnabled": true,
  "onedriveClientId": "your-onedrive-client-id",
  "onedriveClientSecret": "your-onedrive-client-secret"
}'
```
</CodeGroup>

<Warning>
  Once you enable custom keys for a provider, all new connections for that provider will use your custom OAuth application. Existing connections WILL need to be re-authorized.
</Warning>