diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2021-05-14 19:19:10 +0200 |
---|---|---|
committer | Rigel Kent <sendmemail@rigelk.eu> | 2021-05-14 19:19:10 +0200 |
commit | 3cf8874f1a0ba8a0f326b439d1155b2142b61563 (patch) | |
tree | d3b00e7e2441dc992df87a3c929a702afc67fa8c /support/doc | |
parent | 5b1a6d45b5d6e50102e1c7c8c845401b76b11b4d (diff) | |
download | PeerTube-3cf8874f1a0ba8a0f326b439d1155b2142b61563.tar.gz PeerTube-3cf8874f1a0ba8a0f326b439d1155b2142b61563.tar.zst PeerTube-3cf8874f1a0ba8a0f326b439d1155b2142b61563.zip |
add code examples for login in openapi spec
Diffstat (limited to 'support/doc')
-rw-r--r-- | support/doc/api/openapi.yaml | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml index fc62f95bb..db89153d7 100644 --- a/support/doc/api/openapi.yaml +++ b/support/doc/api/openapi.yaml | |||
@@ -809,6 +809,13 @@ paths: | |||
809 | parameters: | 809 | parameters: |
810 | client_id: '$response.body#/client_id' | 810 | client_id: '$response.body#/client_id' |
811 | client_secret: '$response.body#/client_secret' | 811 | client_secret: '$response.body#/client_secret' |
812 | x-codeSamples: | ||
813 | - lang: Shell | ||
814 | source: | | ||
815 | API="https://peertube2.cpy.re/api/v1" | ||
816 | |||
817 | ## AUTH | ||
818 | curl -s "$API/oauth-clients/local" | ||
812 | /users/token: | 819 | /users/token: |
813 | post: | 820 | post: |
814 | summary: Login | 821 | summary: Login |
@@ -855,6 +862,24 @@ paths: | |||
855 | type: integer | 862 | type: integer |
856 | minimum: 0 | 863 | minimum: 0 |
857 | example: 1209600 | 864 | example: 1209600 |
865 | x-codeSamples: | ||
866 | - lang: Shell | ||
867 | source: | | ||
868 | ## DEPENDENCIES: jq | ||
869 | API="https://peertube2.cpy.re/api/v1" | ||
870 | USERNAME="<your_username>" | ||
871 | PASSWORD="<your_password>" | ||
872 | |||
873 | ## AUTH | ||
874 | client_id=$(curl -s "$API/oauth-clients/local" | jq -r ".client_id") | ||
875 | client_secret=$(curl -s "$API/oauth-clients/local" | jq -r ".client_secret") | ||
876 | curl -s "$API/users/token" \ | ||
877 | --data client_id="$client_id" \ | ||
878 | --data client_secret="$client_secret" \ | ||
879 | --data grant_type=password \ | ||
880 | --data username="$USERNAME" \ | ||
881 | --data password="$PASSWORD" \ | ||
882 | | jq -r ".access_token" | ||
858 | /users/revoke-token: | 883 | /users/revoke-token: |
859 | post: | 884 | post: |
860 | summary: Logout | 885 | summary: Logout |
@@ -1714,21 +1739,21 @@ paths: | |||
1714 | FILE_PATH="<your_file_path>" | 1739 | FILE_PATH="<your_file_path>" |
1715 | CHANNEL_ID="<your_channel_id>" | 1740 | CHANNEL_ID="<your_channel_id>" |
1716 | NAME="<video_name>" | 1741 | NAME="<video_name>" |
1742 | API="https://peertube2.cpy.re/api/v1" | ||
1717 | 1743 | ||
1718 | API_PATH="https://peertube2.cpy.re/api/v1" | ||
1719 | ## AUTH | 1744 | ## AUTH |
1720 | client_id=$(curl -s "$API_PATH/oauth-clients/local" | jq -r ".client_id") | 1745 | client_id=$(curl -s "$API/oauth-clients/local" | jq -r ".client_id") |
1721 | client_secret=$(curl -s "$API_PATH/oauth-clients/local" | jq -r ".client_secret") | 1746 | client_secret=$(curl -s "$API/oauth-clients/local" | jq -r ".client_secret") |
1722 | token=$(curl -s "$API_PATH/users/token" \ | 1747 | token=$(curl -s "$API/users/token" \ |
1723 | --data client_id="$client_id" \ | 1748 | --data client_id="$client_id" \ |
1724 | --data client_secret="$client_secret" \ | 1749 | --data client_secret="$client_secret" \ |
1725 | --data grant_type=password \ | 1750 | --data grant_type=password \ |
1726 | --data response_type=code \ | ||
1727 | --data username="$USERNAME" \ | 1751 | --data username="$USERNAME" \ |
1728 | --data password="$PASSWORD" \ | 1752 | --data password="$PASSWORD" \ |
1729 | | jq -r ".access_token") | 1753 | | jq -r ".access_token") |
1754 | |||
1730 | ## VIDEO UPLOAD | 1755 | ## VIDEO UPLOAD |
1731 | curl -s "$API_PATH/videos/upload" \ | 1756 | curl -s "$API/videos/upload" \ |
1732 | -H "Authorization: Bearer $token" \ | 1757 | -H "Authorization: Bearer $token" \ |
1733 | --max-time 600 \ | 1758 | --max-time 600 \ |
1734 | --form videofile=@"$FILE_PATH" \ | 1759 | --form videofile=@"$FILE_PATH" \ |