You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
metaDescription: 'A TypeScript SDK for the Prisma Data Platform Management API with built-in OAuth authentication and automatic token refresh.'
4
+
metaDescription: 'A TypeScript SDK for the Prisma Data Platform Management API. Use the simple client for direct API access, or the full SDK with built-in OAuth authentication and automatic token refresh.'
5
5
---
6
6
7
7
## Overview
8
8
9
-
The [`@prisma/management-api-sdk`](https://www.npmjs.com/package/@prisma/management-api-sdk) is a TypeScript SDK for the [Prisma Data Platform Management API](/postgres/introduction/management-api) with built-in OAuth authentication and automatic token refresh.
9
+
The [`@prisma/management-api-sdk`](https://www.npmjs.com/package/@prisma/management-api-sdk) is a TypeScript SDK for the [Prisma Data Platform Management API](/postgres/introduction/management-api). Use the simple client for direct API access, or the full SDK with built-in OAuth authentication and automatic token refresh.
10
+
11
+
Based on the [public OpenAPI 3.1 specification](https://api.prisma.io/v1/swagger-editor).
10
12
11
13
## Installation
12
14
13
15
```terminal
14
16
npm install @prisma/management-api-sdk
15
17
```
16
18
17
-
## Quick start
19
+
## Basic usage
20
+
21
+
For usage with an existing access or [service token](/postgres/introduction/management-api#service-tokens).
22
+
23
+
### Making API calls
24
+
25
+
The client provides fully typed methods for all API endpoints:
If you provide both `token` and `headers.Authorization`, the `headers.Authorization` takes precedence. The `baseUrl` defaults to `https://api.prisma.io` if not provided.
84
+
85
+
:::
86
+
87
+
## Advanced usage
88
+
89
+
For applications that need [OAuth authentication](/postgres/introduction/management-api#oauth-20-authentication), automatic token refresh, and token storage management, use the full SDK.
90
+
91
+
### OAuth authentication flow
92
+
93
+
The SDK uses OAuth 2.0 with PKCE for secure authentication. The flow is stateless - you're responsible for storing the `state` and `verifier` between the login URL generation and callback handling.
The SDK uses OAuth 2.0 with PKCE for secure authentication. The flow is stateless - you're responsible for storing the state and verifier between the login URL generation and callback handling.
50
-
51
-
### 1. Initiate login
122
+
#### 2. Initiate login
52
123
53
124
Generate the OAuth login URL. The returned `state` and `verifier` must be stored (e.g., in a session or cookie) for use when handling the callback:
When the user is redirected back to your app, retrieve the stored state and verifier and pass them to `handleCallback`. On success, tokens are automatically stored via your `tokenStorage` implementation:
145
+
When the user is redirected back to your app, retrieve the stored `state` and `verifier` and pass them to `handleCallback`. On success, tokens are automatically stored via your `tokenStorage` implementation:
75
146
76
147
```typescript
77
148
// In your callback route handler
@@ -101,7 +172,7 @@ try {
101
172
}
102
173
```
103
174
104
-
###3. Make API calls
175
+
#### 4. Make API calls
105
176
106
177
The client automatically includes authentication headers and refreshes tokens when they expire:
0 commit comments