@@ -11,6 +11,8 @@ You can use our [React hooks](/frontend/react-hooks) in your frontend applicatio
11
11
To create a Public Access Token, you can use the ` auth.createPublicToken ` function in your ** backend** code:
12
12
13
13
``` tsx
14
+ import { auth } from " @trigger.dev/sdk/v3" ;
15
+
14
16
const publicToken = await auth .createPublicToken (); // 👈 this public access token has no permissions, so is pretty useless!
15
17
```
16
18
@@ -19,6 +21,8 @@ const publicToken = await auth.createPublicToken(); // 👈 this public access t
19
21
By default a Public Access Token has no permissions. You must specify the scopes you need when creating a Public Access Token:
20
22
21
23
``` ts
24
+ import { auth } from " @trigger.dev/sdk/v3" ;
25
+
22
26
const publicToken = await auth .createPublicToken ({
23
27
scopes: {
24
28
read: {
@@ -31,6 +35,8 @@ const publicToken = await auth.createPublicToken({
31
35
This will allow the token to read all runs, which is probably not what you want. You can specify only certain runs by passing an array of run IDs:
32
36
33
37
``` ts
38
+ import { auth } from " @trigger.dev/sdk/v3" ;
39
+
34
40
const publicToken = await auth .createPublicToken ({
35
41
scopes: {
36
42
read: {
@@ -43,6 +49,8 @@ const publicToken = await auth.createPublicToken({
43
49
You can scope the token to only read certain tasks:
44
50
45
51
``` ts
52
+ import { auth } from " @trigger.dev/sdk/v3" ;
53
+
46
54
const publicToken = await auth .createPublicToken ({
47
55
scopes: {
48
56
read: {
@@ -55,6 +63,8 @@ const publicToken = await auth.createPublicToken({
55
63
Or tags:
56
64
57
65
``` ts
66
+ import { auth } from " @trigger.dev/sdk/v3" ;
67
+
58
68
const publicToken = await auth .createPublicToken ({
59
69
scopes: {
60
70
read: {
@@ -67,6 +77,8 @@ const publicToken = await auth.createPublicToken({
67
77
Or a specific batch of runs:
68
78
69
79
``` ts
80
+ import { auth } from " @trigger.dev/sdk/v3" ;
81
+
70
82
const publicToken = await auth .createPublicToken ({
71
83
scopes: {
72
84
read: {
@@ -79,6 +91,8 @@ const publicToken = await auth.createPublicToken({
79
91
You can also combine scopes. For example, to read runs with specific tags and for specific tasks:
80
92
81
93
``` ts
94
+ import { auth } from " @trigger.dev/sdk/v3" ;
95
+
82
96
const publicToken = await auth .createPublicToken ({
83
97
scopes: {
84
98
read: {
@@ -94,6 +108,8 @@ const publicToken = await auth.createPublicToken({
94
108
By default, Public Access Token's expire after 15 minutes. You can specify a different expiration time when creating a Public Access Token:
95
109
96
110
``` ts
111
+ import { auth } from " @trigger.dev/sdk/v3" ;
112
+
97
113
const publicToken = await auth .createPublicToken ({
98
114
expirationTime: " 1hr" ,
99
115
});
@@ -120,6 +136,8 @@ console.log(handle.publicAccessToken);
120
136
By default, tokens returned from the ` trigger ` function expire after 15 minutes and have a read scope for that specific run. You can customize the expiration of the auto-generated tokens by passing a ` publicTokenOptions ` object to the ` trigger ` function:
121
137
122
138
``` ts
139
+ import { tasks } from " @trigger.dev/sdk/v3" ;
140
+
123
141
const handle = await tasks .trigger (
124
142
" my-task" ,
125
143
{ some: " data" },
0 commit comments