Skip to content

Commit e566c16

Browse files
committed
fix(tokens): minor changes
1 parent ab10858 commit e566c16

File tree

1 file changed

+34
-26
lines changed

1 file changed

+34
-26
lines changed

sqlite-cloud/platform/access-tokens.mdx

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
---
22
title: Access Tokens
3-
description: Grant to your users, devices, tenant, access to SQLite Cloud services.
3+
description: Grant to your users, devices, tenant, access to SQLite Cloud database and services.
44
category: platform
55
status: publish
66
slug: access-tokens
77
---
88

99
# Access Token API
1010

11-
Access Tokens let backend systems securely grant users, devices, tenants, etc. access to SQLite Cloud services (SQLite Sync, Weblite, etc.). These endpoints enable full token lifecycle management: creation, inspection, validation, update, and revocation.
11+
Access Tokens let backend systems securely grant users, devices, tenants, etc. access to SQLite Cloud database and services (SQLite Sync, Weblite, etc.). These endpoints enable full token lifecycle management: creation, inspection, validation, update, and revocation.
1212
All endpoints require authentication. Use an **API Key** or an **Access Token** via the `Authorization` header.
1313

1414
---
@@ -17,9 +17,9 @@ All endpoints require authentication. Use an **API Key** or an **Access Token**
1717

1818
### `POST /v2/tokens`
1919

20-
Creates a new Access Token for a specific entity.
21-
The `entityId` refers to any kind of resource you want to associate the Access Token with. It must be a unique ID in your system.
22-
The `expiresAt` is a date time value to set an expiration, or `null` if it doesn't expire.
20+
Creates a new Access Token for a specific user.
21+
The `userId` refers to your user's id or any kind of resource you want to associate the Access Token to. It must be a unique ID in your system.
22+
The `expiresAt` is a date time value to set expiration, or `null` if it doesn't expire.
2323

2424
>[!note] Store the Access Token securely. It will not be shown again.
2525
@@ -29,12 +29,13 @@ The `expiresAt` is a date time value to set an expiration, or `null` if it doesn
2929

3030
```bash
3131
curl -X 'POST' \
32-
'https://<your-project-id>.sqlite.cloud:443/v2/tokens' \
32+
'https://<your-project-domain>.sqlite.cloud/v2/tokens' \
3333
-H 'Content-Type: application/json' \
34-
-H 'Authorization: Bearer sqlitecloud://<your-project-id>.sqlite.cloud:8860?apikey=<your-api-key>' \
34+
-H 'Authorization: Bearer <your-api-key>' \
3535
-d '{
36-
"entityId": "0195fc5b-96a6-7000-8b17-fd2420499c2c",
36+
"userId": "0195fc5b-96a6-7000-8b17-fd2420499c2c",
3737
"name": "user-token",
38+
"attributes": "{\"role\":\"myrole\"}",
3839
"expiresAt": "2023-10-01 10:11:12"
3940
}'
4041
```
@@ -46,8 +47,9 @@ curl -X 'POST' \
4647
"data": {
4748
"token": "134|sqla_abcdeabcdeabcdeabcdeabcdeabcde",
4849
"access_token_id": 134,
49-
"entityId": "0195fc5b-96a6-7000-8b17-fd2420499c2c",
50+
"userId": "0195fc5b-96a6-7000-8b17-fd2420499c2c",
5051
"name": "user-token",
52+
"attributes": "{\"role\":\"myrole\"}",
5153
"expiresAt": "2023-10-01 10:11:12",
5254
"createdAt": "2023-09-01 10:11:12"
5355
}
@@ -68,7 +70,7 @@ Retrieves metadata about the token used to authenticate the request.
6870

6971
```bash
7072
curl -X 'GET' \
71-
'https://<your-project-id>.sqlite.cloud:443/v2/tokens/details' \
73+
'https://<your-project-domain>.sqlite.cloud/v2/tokens/details' \
7274
-H 'accept: application/json' \
7375
-H 'Authorization: Bearer 134|sqla_abcdeabcdeabcdeabcdeabcdeabcde'
7476
```
@@ -79,8 +81,9 @@ curl -X 'GET' \
7981
{
8082
"data": {
8183
"access_token_id": 134,
82-
"entityId": "0195fc5b-96a6-7000-8b17-fd2420499c2c",
84+
"userId": "0195fc5b-96a6-7000-8b17-fd2420499c2c",
8385
"name": "user-token",
86+
"attributes": null,
8487
"expiresAt": "2023-10-01 10:11:12",
8588
"createdAt": "2023-09-01 10:11:12"
8689
}
@@ -101,9 +104,9 @@ Lets you inspect an Access Token using your API Key.
101104

102105
```bash
103106
curl -X 'POST' \
104-
'https://<your-project-id>.sqlite.cloud:443/v2/tokens/details' \
107+
'https://<your-project-domain>.sqlite.cloud/v2/tokens/details' \
105108
-H 'Content-Type: application/json' \
106-
-H 'Authorization: Bearer sqlitecloud://<your-project-id>.sqlite.cloud:8860?apikey=<your-api-key>' \
109+
-H 'Authorization: Bearer <your-api-key>' \
107110
-d '{
108111
"token": "134|sqla_abcdeabcdeabcdeabcdeabcdeabcde"
109112
}'
@@ -115,8 +118,9 @@ curl -X 'POST' \
115118
{
116119
"data": {
117120
"access_token_id": 134,
118-
"entityId": "0195fc5b-96a6-7000-8b17-fd2420499c2c",
121+
"userId": "0195fc5b-96a6-7000-8b17-fd2420499c2c",
119122
"name": "user-token",
123+
"attributes": null,
120124
"expiresAt": "2023-10-01 10:11:12",
121125
"createdAt": "2023-09-01 10:11:12"
122126
}
@@ -137,19 +141,23 @@ Checks whether the provided Access Token is valid and not expired.
137141

138142
```bash
139143
curl -X 'GET' \
140-
'https://<your-project-id>.sqlite.cloud:443/v2/tokens/authorized' \
144+
'https://<your-project-domain>.sqlite.cloud/v2/tokens/authorized' \
141145
-H 'accept: application/json' \
142146
-H 'Authorization: Bearer 134|sqla_abcdeabcdeabcdeabcdeabcdeabcde'
143147
```
144148

149+
#### Example Response
150+
151+
HTTP Status **204** or **401** if not valid or expired.
152+
145153
---
146154

147155
## Update an Access Token
148156

149157
### `PATCH /v2/tokens`
150158

151159
Updates information of an Access Token.
152-
The The `token` field is required; it specifies the Access Token to update.
160+
The `token` field is required, it specifies the Access Token to update.
153161
Fields that can be updated:
154162
- `name`.
155163
- `expiresAt`: date time value or `null` to set no expiration.
@@ -160,10 +168,10 @@ Fields that can be updated:
160168

161169
```bash
162170
curl -X 'PATCH' \
163-
'https://<your-project-id>.sqlite.cloud:443/v2/tokens' \
171+
'https://<your-project-domain>.sqlite.cloud/v2/tokens' \
164172
-H 'accept: application/json' \
165173
-H 'Content-Type: application/json' \
166-
-H 'Authorization: Bearer sqlitecloud://<your-project-id>.sqlite.cloud:8860?apikey=<your-api-key>' \
174+
-H 'Authorization: Bearer <your-api-key>' \
167175
-d '{
168176
"token": "134|sqla_abcdeabcdeabcdeabcdeabcdeabcde",
169177
"name": "updated-user-token",
@@ -187,33 +195,33 @@ The `token` in the request is optional when the Access Token is used for the aut
187195

188196
```bash
189197
curl -X 'DELETE' \
190-
'https://<your-project-id>.sqlite.cloud:443/v2/tokens' \
198+
'https://<your-project-domain>.sqlite.cloud/v2/tokens' \
191199
-H 'accept: application/json' \
192200
-H 'Content-Type: application/json' \
193-
-H 'Authorization: Bearer sqlitecloud://<your-project-id>.sqlite.cloud:8860?apikey=<your-api-key>' \
201+
-H 'Authorization: Bearer <your-api-key>' \
194202
-d '{
195203
"token": "134|sqla_abcdeabcdeabcdeabcdeabcdeabcde"
196204
}'
197205
```
198206

199207
---
200208

201-
## List Tokens by Entity
209+
## List Tokens by User
202210

203-
### `GET /v2/tokens/entities/{entityId}`
211+
### `GET /v2/tokens/users/{userId}`
204212

205-
Returns all non-expired tokens associated with the specified entity.
213+
Returns all non-expired tokens associated with the specified user.
206214

207215
- **Authentication**: API Key
208-
- **Path Parameter**: `entityId`
216+
- **Path Parameter**: `userId`
209217

210218
#### Example
211219

212220
```bash
213221
curl -X 'GET' \
214-
'https://<your-project-id>.sqlite.cloud:443/v2/tokens/entities/0195fc5b-96a6-7000-8b17-fd2420499c2c' \
222+
'https://<your-project-domain>.sqlite.cloud/v2/tokens/users/0195fc5b-96a6-7000-8b17-fd2420499c2c' \
215223
-H 'accept: application/json' \
216-
-H 'Authorization: Bearer sqlitecloud://<your-project-id>.sqlite.cloud:8860?apikey=<your-api-key>'
224+
-H 'Authorization: Bearer <your-api-key>'
217225
```
218226

219227
#### Example Response

0 commit comments

Comments
 (0)