Skip to content

Commit d806bfd

Browse files
committed
review: share obtain-token.sh
1 parent ebdf528 commit d806bfd

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

getting-started/assets/polaris/create-catalog.sh

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,16 @@ apk add --no-cache jq
2323

2424
realm=${1:-"POLARIS"}
2525

26-
token=${2:-""}
26+
TOKEN=${2:-""}
2727

28-
if [ -z "$token" ]; then
29-
token=$(curl -s http://polaris:8181/api/catalog/v1/oauth/tokens \
30-
--user ${CLIENT_ID}:${CLIENT_SECRET} \
31-
-H "Polaris-Realm: $realm" \
32-
-d grant_type=client_credentials \
33-
-d scope=PRINCIPAL_ROLE:ALL | jq -r .access_token)
28+
BASEDIR=$(dirname $0)
3429

35-
if [ -z "${token}" ]; then
36-
echo "Failed to obtain access token."
37-
exit 1
38-
fi
30+
if [ -z "$TOKEN" ]; then
31+
source $BASEDIR/obtain-token.sh
3932
fi
4033

4134
echo
42-
echo "Obtained access token: ${token}"
35+
echo "Obtained access token: ${TOKEN}"
4336

4437
STORAGE_TYPE="FILE"
4538
if [ -z "${STORAGE_LOCATION}" ]; then
@@ -84,7 +77,7 @@ PAYLOAD='{
8477

8578
echo $PAYLOAD
8679

87-
curl -s -H "Authorization: Bearer ${token}" \
80+
curl -s -H "Authorization: Bearer ${TOKEN}" \
8881
-H 'Accept: application/json' \
8982
-H 'Content-Type: application/json' \
9083
-H "Polaris-Realm: $realm" \

0 commit comments

Comments
 (0)