зеркало из https://github.com/nextcloud/social.git
Created Testing the API (markdown)
Родитель
3a50b3944b
Коммит
cf12f7d3c1
|
@ -0,0 +1,61 @@
|
|||
|
||||
### Creating the App
|
||||
|
||||
This is the first request a 3rd party client would need to send:
|
||||
|
||||
```
|
||||
curl -X POST https://your.nextcloud.com/index.php/apps/social/api/v1/apps \
|
||||
-d "client_name=curl&redirect_uris=https://test.example.net/oauth/redirected&scopes=write+read&website=https://test.example.net"
|
||||
```
|
||||
|
||||
should returns:
|
||||
> ```
|
||||
>{
|
||||
> "id": 1,
|
||||
> "name": "curl",
|
||||
> "website": "https://test.example.net",
|
||||
> "scopes": "write read",
|
||||
> "client_id": "zahscLgi9rZp5SpiOuXGHoqZGAziMhlXVgmTM4Fl",
|
||||
> "client_secret": "xcDAPQLISsAw4UKqrut1OarDuCXf3IzOJxXQesHs"
|
||||
>}
|
||||
> ```
|
||||
|
||||
|
||||
|
||||
### Authorize App, identify Account
|
||||
|
||||
Open a browser and go to the generated URL using `client_id`:
|
||||
|
||||
|
||||
> https://your.nextcloud.com/index.php/apps/social/oauth/authorize?response_type=code&scope=write+read&redirect_uri=https://test.example.net/oauth/redirected&client_id=zahscLgi9rZp5SpiOuXGHoqZGAziMhlXVgmTM4Fl
|
||||
|
||||
|
||||
After authentication, using the credentials of your Nextcloud account, you will be redirected to `https://test.example.net/oauth/redirected?code=VcIgHmSYPYrgrHyM8kRDxf4Gz-dJOuoNBuEz9mlZtw4`
|
||||
|
||||
|
||||
|
||||
### Obtain token
|
||||
|
||||
Once you have a `code`:
|
||||
|
||||
```
|
||||
curl -X POST https://your.nextcloud.com/index.php/apps/social/oauth/token \
|
||||
-d "client_id=zahscLgi9rZp5SpiOuXGHoqZGAziMhlXVgmTM4Fl&redirect_uri=https://test.example.net/oauth/redirected&client_secret=xcDAPQLISsAw4UKqrut1OarDuCXf3IzOJxXQesHs&grant_type=authorization_code&code=VcIgHmSYPYrgrHyM8kRDxf4Gz-dJOuoNBuEz9mlZtw4"
|
||||
```
|
||||
|
||||
result will be:
|
||||
|
||||
> ```
|
||||
>{
|
||||
> "access_token": "7UnD7f1fbMUUGqRalX0cTSW5H-Ion40_at560DsvG1w",
|
||||
> "token_type": "Bearer",
|
||||
> "scope": "write read",
|
||||
> "created_at": 1600354593
|
||||
>}
|
||||
> ```
|
||||
|
||||
|
||||
### Navigating the API
|
||||
|
||||
The `access_token` will be needed to request the API:
|
||||
|
Загрузка…
Ссылка в новой задаче