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
Copy file name to clipboardExpand all lines: docs/realtime/auth.mdx
+7-8Lines changed: 7 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,18 +10,19 @@ To use the Realtime API, you need to authenticate your requests with Public Acce
10
10
11
11
There are two types of tokens you can use with the Realtime API:
12
12
13
-
-**[Public Access Tokens](#public-access-tokens-for-subscribing-to-runs)** - Used to read and subscribe to run data. Can be used in both frontend and backend applications.
14
-
-**[Trigger Tokens](#trigger-tokens-for-frontend-triggering-only)** - Used to trigger tasks from your frontend. These are more secure, single-use tokens that can only be used in frontend applications.
13
+
-**[Public Access Tokens](#public-access-tokens-for-subscribing-to-runs)** - Used to read and subscribe to run data. Can be used in both the frontend and backend.
14
+
-**[Trigger Tokens](#trigger-tokens-for-frontend-triggering-only)** - Used to trigger tasks from your frontend. These are more secure, single-use tokens that can only be used in the frontend.
15
15
16
16
## Public Access Tokens (for subscribing to runs)
17
17
18
-
Public Access Tokens are used to read and subscribe to run data. They can be used in both frontend and backend applications to subscribe to runs.
18
+
Use Public Access Tokens to subscribe to runs and receive real-time updates in your frontend or backend.
19
19
20
20
### Creating Public Access Tokens
21
21
22
22
You can create a Public Access Token using the `auth.createPublicToken` function in your **backend** code:
23
23
24
24
```tsx
25
+
// Somewhere in your backend code
25
26
import { auth } from"@trigger.dev/sdk/v3";
26
27
27
28
const publicToken =awaitauth.createPublicToken(); // 👈 this public access token has no permissions, so is pretty useless!
@@ -144,7 +145,7 @@ See our [triggering documentation](/triggering) for detailed examples of how to
144
145
145
146
Once you have a Public Access Token, you can use it to authenticate requests to the Realtime API in both backend and frontend applications.
146
147
147
-
**Backend usage:** See our [backend subscription documentation](/realtime/backend/subscribe) for examples of using tokens with backend functions.
148
+
**Backend usage:** See our [backend documentation](/realtime/backend) for examples of what you can do with Realtime in your backend once you have authenticated with a token.
148
149
149
150
**Frontend usage:** See our [React hooks documentation](/realtime/react-hooks) for examples of using tokens with frontend components.
### Triggering tasks from frontend with Trigger Tokens
202
-
203
-
To trigger tasks from your frontend, you need to use special Trigger Tokens created in your backend. See our [React hooks triggering documentation](/realtime/react-hooks/triggering) for complete examples.
202
+
### Triggering tasks from the frontend with Trigger Tokens
204
203
205
-
See our [React hooks documentation](/realtime/react-hooks) for more details on using hooks in your frontend application.
204
+
Check out our [React hooks documentation](/realtime/react-hooks) for examples of how to use Trigger Tokens in your frontend applications.
0 commit comments