Improve REST api getting started guide

This commit is contained in:
Chocobozzz
2026-03-05 15:37:27 +01:00
parent af585a8c3a
commit ae362aae20
2 changed files with 31 additions and 2 deletions
+29 -2
View File
@@ -14,10 +14,20 @@ There are several ways to know if a website uses the PeerTube software:
Some endpoints need authentication. We use OAuth 2.0 so first fetch the client tokens:
```bash
::: code-group
```bash [Curl]
curl https://peertube.example.com/api/v1/oauth-clients/local
```
```js [JS]
const { client_id, client_secret } = await fetch('https://peertube.example.com/api/v1/oauth-clients/local', {
headers: { 'Content-Type': 'application/json' }
}).then(res => res.json())
```
:::
Response example:
```json
@@ -31,12 +41,29 @@ Response example:
Now you can fetch the user token:
```bash
::: code-group
```bash [Curl]
curl -X POST \
-d "client_id=v1ikx5hnfop4mdpnci8nsqh93c45rldf&client_secret=AjWiOapPltI6EnsWQwlFarRtLh4u8tDt&grant_type=password&response_type=code&username=your_user&password=your_password" \
https://peertube.example.com/api/v1/users/token
```
```js [JS]
const { access_token } = await fetch('https://peertube.example.com/api/v1/users/token', {
contentType: 'application/x-www-form-urlencoded',
method: 'POST',
body: new URLSearchParams({
client_id: '...',
client_secret: '...',
username: '...',
password: '...',
grant_type: 'password'
})
}).then(res => res.json())
```
:::
Response example:
```json