diff --git a/data-collectors/parking-offstreet-sta/calls.http b/data-collectors/parking-offstreet-sta/calls.http index d274e280..a6da183a 100644 --- a/data-collectors/parking-offstreet-sta/calls.http +++ b/data-collectors/parking-offstreet-sta/calls.http @@ -11,13 +11,14 @@ ### Get access token for the writer (LOCAL DEV) # @name login -GET https://www.onecenter.info/oauth/token -?grant_type=password +POST https://www.onecenter.info/oauth/token +Content-Type: application/x-www-form-urlencoded + +grant_type=password &username={{username}} &client_id={{clientId}} &client_secret={{secret}} &password={{password}} -Content-Type: application/x-www-form-urlencoded diff --git a/data-collectors/parking-offstreet-sta/curl-calls.sh b/data-collectors/parking-offstreet-sta/curl-calls.sh index 1564a14a..aefed90d 100644 --- a/data-collectors/parking-offstreet-sta/curl-calls.sh +++ b/data-collectors/parking-offstreet-sta/curl-calls.sh @@ -4,7 +4,10 @@ # # SPDX-License-Identifier: CC0-1.0 +###################### # load .env +###################### + if [ -f .env ]; then set -a source .env @@ -16,19 +19,49 @@ else exit 1 fi -BASE_URL=https://www.onecenter.info -AUTH_URL=/oauth/token +###################### +# define variables +###################### + +BASE_URL=https://online.onecenter.info FACILITY_PATH=/api/Facility/GetFacilities FREE_PLACES_PATH=/api/Facility/GetFreePlaces +###################### # auth +###################### + printf "\nauth\n" -CURL="curl -H 'Content-Type:application/x-www-form-urlencoded'" -URL="$API_OAUTH_TOKEN_URI?grant_type=password&username=$API_OAUTH_USERNAME&client_id=STA&client_secret=$API_OAUTH_PASSWORD&password=$API_OAUTH_PASSWORD" +RESPONSE=$(curl --request POST \ + --url "$API_OAUTH_TOKEN_URI" \ + --header "Content-Type: application/x-www-form-urlencoded" \ + --data grant_type=password \ + --data username=$API_OAUTH_USERNAME \ + --data client_id=STA \ + --data client_secret=$API_OAUTH_CLIENT_SECRET \ + --data password=$API_OAUTH_PASSWORD + ) + +printf "\n$RESPONSE\n" + +TOKEN=$(echo $RESPONSE | jq --raw-output '.access_token') + +# printf "Token: $TOKEN" -printf "$CURL $URL \n" -$CURL "$URL" printf "\n###############\n" + +###################### +# facilities +###################### + +printf "\nfacilities\n" + +curl --url "$BASE_URL$FACILITY_PATH" \ + --header "Authorization: Bearer $TOKEN" | jq + + +printf "\n###############\n" +