Mercurial > prosody-modules
comparison mod_rest/example/rest.sh @ 5430:48c643c851f3
mod_rest/rest.sh: Make scopes to request configurable in restrc
Makes it easier to experiment with requesting various scopes and roles
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 07 May 2023 20:41:35 +0200 |
parents | e3fc52b40064 |
children | 95cb7e7efa37 |
comparison
equal
deleted
inserted
replaced
5429:0bbeee8ba8b5 | 5430:48c643c851f3 |
---|---|
87 fi | 87 fi |
88 fi | 88 fi |
89 | 89 |
90 if [ -z "${ACCESS_TOKEN:-}" ]; then | 90 if [ -z "${ACCESS_TOKEN:-}" ]; then |
91 CODE_CHALLENGE="$(head -c 33 /dev/urandom | base64 | tr /+ _-)" | 91 CODE_CHALLENGE="$(head -c 33 /dev/urandom | base64 | tr /+ _-)" |
92 open "$AUTHORIZATION_ENDPOINT?response_type=code&client_id=$CLIENT_ID&code_challenge=$CODE_CHALLENGE&scope=openid+prosody:user" | 92 open "$AUTHORIZATION_ENDPOINT?response_type=code&client_id=$CLIENT_ID&code_challenge=$CODE_CHALLENGE&scope=${SCOPE:-openid+prosody:user}" |
93 read -p "Paste authorization code: " -s -r AUTHORIZATION_CODE | 93 read -p "Paste authorization code: " -s -r AUTHORIZATION_CODE |
94 | 94 |
95 TOKEN_RESPONSE="$(http --check-status --form "$TOKEN_ENDPOINT" 'grant_type=authorization_code' "client_id=$CLIENT_ID" "client_secret=$CLIENT_SECRET" "code=$AUTHORIZATION_CODE" code_verifier="$CODE_CHALLENGE")" | 95 TOKEN_RESPONSE="$(http --check-status --form "$TOKEN_ENDPOINT" 'grant_type=authorization_code' "client_id=$CLIENT_ID" "client_secret=$CLIENT_SECRET" "code=$AUTHORIZATION_CODE" code_verifier="$CODE_CHALLENGE")" |
96 ACCESS_TOKEN="$(echo "$TOKEN_RESPONSE" | jq -e -r '.access_token')" | 96 ACCESS_TOKEN="$(echo "$TOKEN_RESPONSE" | jq -e -r '.access_token')" |
97 REFRESH_TOKEN="$(echo "$TOKEN_RESPONSE" | jq -r '.refresh_token')" | 97 REFRESH_TOKEN="$(echo "$TOKEN_RESPONSE" | jq -r '.refresh_token')" |