-
Notifications
You must be signed in to change notification settings - Fork 1
API
Matt Poegel edited this page May 13, 2024
·
1 revision
The interface aims to follow the jsonapi. The schema can be found in pkg/api/types.go
.
First get an access token using your username and password.
JWT=$(curl -s -X POST https://pizza.oldno.name:443/api/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d username=$USERNAME \
-d password=$PASSWORD \
-d grant_type=password)
TOKEN=$(echo $JWT | jq -r .access_token)
Fetch fridays.
curl -s -X GET https://pizza.oldno.name:443/api/friday \
-H 'Accept: application/vnd.api+json' \
-H "Authorization: Bearer $TOKEN"
RSVP to a friday.
curl -s -X PATCH https://pizza.oldno.name:443/api/friday \
-H 'Content-Type: application/vnd.api+json' \
-H 'Accept: application/vnd.api+json' \
-H "Authorization: Bearer $TOKEN" \
--data '{"data": { "type": "friday", "id": "123456789", "relationships": { "guests": { "data": [{ "type": "guest", "id": "[email protected]" }] } } } }'
Use the refresh token to get a new access token.
REFRESH_TOKEN=$(echo $JWT | jq -r .refresh_token)
JWT=$(curl -s -X POST https://pizza.oldno.name:443/api/token \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d refresh_token=$REFRESH_TOKEN \
-d grant_type=refresh_token)
TOKEN=$(echo $JWT | jq -r .access_token)