mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2026-09-03 20:53:09 -05:00
Improve REST api getting started guide
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user