Skip to content

Commit fe400ef

Browse files
committed
Merge branch 'introduce-access-tokens' into stage
2 parents 821dcc1 + fd5da60 commit fe400ef

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

sqlite-cloud/platform/access-tokens.mdx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ slug: access-tokens
88

99
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. All endpoints require authentication. Use an **API Key** or an **Access Token** via the `Authorization` header.
1010

11-
API Documentation can be found in the **Weblite** section in the [Dashboard](https://dashboard.sqlitecloud.io).
11+
The API Documentation for the Access Tokens API can be found in the **Weblite** section in the [Dashboard](https://dashboard.sqlitecloud.io).
1212

1313
---
1414

15+
## Example App
16+
1517
In the repository on GitHub [sqlitecloud/examples](https://github.com/sqlitecloud/examples), we created a simple app to demonstrate how to generate and use Access Tokens.
1618

1719
We’ll log in with Google, grab a token, and use it to interact with SQLite Cloud Weblite APIs. Here’s how it works.
1820

19-
## Generate a new Access Token
20-
2121
In the snippet below, we handle the Google Login callback when the user has completed the login on Google. Here, you can exchange the `code` with the Google Access Token and then decide what to do with it as needed.
2222

2323
```typescript
@@ -34,7 +34,7 @@ if (pathname === "/auth/callback") {
3434
...
3535
```
3636
37-
Now we have authenticated the user, we are ready to request SQLite Cloud to create a new SQLite Cloud Access Token to assign to the this user.
37+
Now we have authenticated the user, we are ready to request SQLite Cloud to create a new SQLite Cloud Access Token assigned to this user.
3838
3939
```typescript
4040
async function getSQLiteCloudToken(userId: string) {
@@ -44,7 +44,7 @@ async function getSQLiteCloudToken(userId: string) {
4444
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24).toISOString(), // expires in 24 hours
4545
};
4646

47-
const res = await fetch(SQLITE_CLOUD_API_TOKENS, {
47+
const res = await fetch("https://<your-project-url>/v2/tokens", {
4848
method: "POST",
4949
headers: {
5050
Authorization: `Bearer ${SQLITE_CLOUD_API_KEY}`,
@@ -65,7 +65,7 @@ In the response JSON, the `data.token` field contains the Access Token.
6565
Finally, the user is authorized to securely access SQLite Cloud services like the Weblite API to perform a query on the database:
6666
6767
```typescript
68-
const res = await fetch(sqliteCloudApiQuery, {
68+
const res = await fetch("https://<your-project-url>/v2/weblite/sql", {
6969
method: "POST",
7070
headers: {
7171
Authorization: "Bearer " + sqliteCloudToken,
@@ -78,4 +78,4 @@ const res = await fetch(sqliteCloudApiQuery, {
7878
...
7979
```
8080
81-
The results depend on the [Row Level Security](https://) you enabled for the tables.
81+
The result depends on the [Row Level Security](https://) you enabled for the tables.

0 commit comments

Comments
 (0)