Skip to content

Commit 13f0768

Browse files
committed
Add missing code samples
1 parent dfc708b commit 13f0768

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

content/4.auth/1.quickstart.md

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Log out of the Data Studio. From the Sign In screen, you will see a new option t
3535

3636
Open your terminal and run the following command to register a new user.
3737

38+
::snippets
39+
#rest
3840
```bash [Terminal]
3941
curl \
4042
--request POST \
@@ -43,12 +45,29 @@ curl \
4345
--url 'https://directus.example.com/register'
4446
```
4547

48+
#graphql
49+
```graphql
50+
mutation {
51+
users_register(email: "[email protected]", password: "d1r3ctu5")
52+
}
53+
```
54+
55+
#sdk
56+
```js
57+
import { createDirectus, rest, registerUser } from '@directus/sdk';
58+
59+
const client = createDirectus('https://directus.example.com').with(rest());
60+
61+
const result = await client.request(registerUser('[email protected]', 'd1r3ctu5'));
62+
```
63+
::
64+
4665
Go to the user directory by clicking :icon{name="user-directory"} in the module bar and you should see a new user has been created.
4766

4867
## Logging In
4968

50-
To log in and get an access token, run the following command.
51-
69+
::snippets
70+
#rest
5271
```bash [Terminal]
5372
curl \
5473
--request POST \
@@ -57,6 +76,29 @@ curl \
5776
--url 'https://directus.example.com/auth/login'
5877
```
5978

79+
#graphql
80+
```graphql
81+
mutation {
82+
auth_login(email: "[email protected]", password: "d1r3ctu5") {
83+
access_token
84+
refresh_token
85+
}
86+
}
87+
```
88+
89+
#sdk
90+
```js
91+
import { createDirectus, authentication } from '@directus/sdk';
92+
93+
const email = "[email protected]";
94+
const password = "d1r3ctu5";
95+
96+
const client = createDirectus('http://directus.example.com').with(authentication());
97+
98+
const token = await client.login(email, password);
99+
```
100+
::
101+
60102
## Authenticating Requests
61103

62104
You can use the access token while making requests. If your token has expired, you must refresh it.

0 commit comments

Comments
 (0)