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
The Prisma Postgres API supports two authentication methods:
40
+
41
+
-**Service tokens** — for accessing resources in your own workspace
42
+
-**OAuth 2.0 access tokens** — for accessing or managing resources on behalf of users
43
+
44
+
### Service tokens
41
45
42
-
The Prisma Postgres API uses _Bearer Token Authentication_ and supports two kinds of tokens:
43
-
- Service tokens (manually created in your [Prisma Console](https://console.prisma.io) workspace)
44
-
- OAuth 2 access tokens
46
+
Service tokens are manually created in your [Prisma Console](https://console.prisma.io) workspace. They're ideal for server-to-server integrations or provisioning databases in your own workspace.
45
47
46
-
To adhere to the Bearer Token Authentication, you need to format your `Authorization` header like this:
48
+
To authenticate with a service token, include it in the `Authorization` header:
47
49
48
50
```
49
51
Authorization: Bearer $TOKEN
50
52
```
51
53
52
54
#### Creating a service token
53
55
54
-
You can create a service token to use the Management API like this:
55
-
56
56
1. Open the [Prisma Console](https://console.prisma.io/).
57
57
2. Navigate to your workspace.
58
-
3. Navigate to the **Settings** page of your workspace and select **Service Tokens**.
59
-
4. Click **New Service Token**.
60
-
5. Copy the generated token and store it in a safe location for future use.
58
+
3. Go to the **Settings** page of your workspace and select **Service Tokens**.
59
+
4. Click **New Service Token** and copy the generated token for future use.
60
+
61
+
### OAuth 2.0 authentication
62
+
63
+
Use OAuth 2.0 if you want to act on behalf of users and create or manage databases directly in their workspaces.
61
64
62
65
#### Creating OAuth credentials
63
66
64
-
To obtain a client ID and client secret, go through this flow:
67
+
To obtain a client ID and client secret:
65
68
66
69
1. Open the [Prisma Console](https://console.prisma.io).
67
-
1. Click the 🧩 **Integrations** tab in the sidenav.
68
-
1. In the **Published Applications** section, click the **New Application** button to start creating a new OAuth app.
69
-
1. Enter a **Name**, **Description**, and **Callback URL** for your OAuth app.
70
-
1. Click **Continue**.
70
+
2. Click the 🧩 **Integrations** tab.
71
+
3. Under **Published Applications**, click **New Application**.
72
+
4. Enter a **Name**, **Description**, and **Redirect URI** (the URL where users will be redirected after authorization).
73
+
5. Click **Continue**, then copy and store your **Client ID** and **Client Secret** to a secure location.
74
+
75
+
#### OAuth authorization flow
76
+
77
+
To use OAuth 2.0, your application must:
78
+
79
+
1.**Redirect users to the authorization URL** with your client ID and redirect URI:
On the next screen, copy and store the client ID and client secret for your OAuth app in a secure location.
101
+
:::note
102
+
The `$CODE` is the authorization code received in step 2 above. The `$REDIRECT_URI` must match exactly what you configured when creating your OAuth credentials.
103
+
:::
73
104
74
-
### Example
105
+
Once you have an access token from the response, include it in requests to the Management API:
Copy file name to clipboardExpand all lines: content/800-guides/330-management-api-basic.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ community_section: true
12
12
13
13
This guide walks you through setting up a basic TypeScript project that uses the [Prisma Postgres Management API](/postgres/introduction/management-api) to create a new [Prisma Console project](/platform/about#project) with a [Prisma Postgres](/postgres/introduction/overview) database, and print out all connection details.
14
14
15
-
You'll authenticate via a [service token](/postgres/introduction/management-api#bearer-tokens), set up your environment, and run a script to interact with the API.
15
+
You'll authenticate via a [service token](/postgres/introduction/management-api#service-tokens), set up your environment, and run a script to interact with the API.
16
16
17
17
:::tip OpenApi
18
18
The API reference is also available via an [OpenAPI 3.1. spec](https://api.prisma.io/v1/swagger-editor).
0 commit comments