Comparison

mod_rest/example/rest.sh @ 5432:1c52efb6fd42

mod_rest/rest.sh: Trim trailing whitespace
author Kim Alvefur <zash@zash.se>
date Sun, 07 May 2023 20:44:44 +0200
parent 5431:95cb7e7efa37
child 5654:b3484a112300
comparison
equal deleted inserted replaced
5431:95cb7e7efa37 5432:1c52efb6fd42
17 17
18 if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" ]; then 18 if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" ]; then
19 # Config file can contain the above settings 19 # Config file can contain the above settings
20 source "${XDG_CONFIG_HOME:-$HOME/.config}/restrc" 20 source "${XDG_CONFIG_HOME:-$HOME/.config}/restrc"
21 fi 21 fi
22 22
23 if [[ $# == 0 ]]; then 23 if [[ $# == 0 ]]; then
24 echo "${0##*/} [-h HOST] [-u USER|--login] [/path] kind=(message|presence|iq) ...." 24 echo "${0##*/} [-h HOST] [-u USER|--login] [/path] kind=(message|presence|iq) ...."
25 # Last arguments are handed to HTTPie, so refer to its docs for further details 25 # Last arguments are handed to HTTPie, so refer to its docs for further details
26 exit 0 26 exit 0
27 fi 27 fi
59 if [[ "$1" == "--login" ]]; then 59 if [[ "$1" == "--login" ]]; then
60 shift 1 60 shift 1
61 61
62 # Check cache for OAuth client 62 # Check cache for OAuth client
63 if [ -f "${XDG_CACHE_HOME:-$HOME/.cache}/rest/$HOST" ]; then 63 if [ -f "${XDG_CACHE_HOME:-$HOME/.cache}/rest/$HOST" ]; then
64 source "${XDG_CACHE_HOME:-$HOME/.cache}/rest/$HOST" 64 source "${XDG_CACHE_HOME:-$HOME/.cache}/rest/$HOST"
65 fi 65 fi
66 66
67 OAUTH_META="$(http --check-status --json "https://$HOST/.well-known/oauth-authorization-server" Accept:application/json)" 67 OAUTH_META="$(http --check-status --json "https://$HOST/.well-known/oauth-authorization-server" Accept:application/json)"
68 AUTHORIZATION_ENDPOINT="$(echo "$OAUTH_META" | jq -e -r '.authorization_endpoint')" 68 AUTHORIZATION_ENDPOINT="$(echo "$OAUTH_META" | jq -e -r '.authorization_endpoint')"
69 TOKEN_ENDPOINT="$(echo "$OAUTH_META" | jq -e -r '.token_endpoint')" 69 TOKEN_ENDPOINT="$(echo "$OAUTH_META" | jq -e -r '.token_endpoint')"