Skip to content

Commit

Permalink
parking-offstreet-sta: fix auth call for calls.http and curl-calls.http
Browse files Browse the repository at this point in the history
  • Loading branch information
dulvui committed Jul 29, 2024
1 parent 56a0777 commit 1aef744
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
7 changes: 4 additions & 3 deletions data-collectors/parking-offstreet-sta/calls.http
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down
45 changes: 39 additions & 6 deletions data-collectors/parking-offstreet-sta/curl-calls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
#
# SPDX-License-Identifier: CC0-1.0

######################
# load .env
######################

if [ -f .env ]; then
set -a
source .env
Expand All @@ -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"

0 comments on commit 1aef744

Please sign in to comment.