From b5f2caf7492dfebb34a2c7173c5d1d868d7d3b84 Mon Sep 17 00:00:00 2001 From: localhost_frssoft Date: Mon, 5 Sep 2022 00:43:02 +0300 Subject: [PATCH] Attempt fix auth helper --- auth_helper.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/auth_helper.sh b/auth_helper.sh index fc7c3c1..d3b4c10 100755 --- a/auth_helper.sh +++ b/auth_helper.sh @@ -17,13 +17,14 @@ export instance_point="https://$instance/api/v1" auth_api_create_client() { + mkdir -m 711 -p ".app_sessions" if [ ! -e ".app_sessions/$instance" ]; then curl -s --compressed --url "$instance_point/apps" \ --data-urlencode "client_name=$client_name" \ --data-urlencode 'redirect_uris=urn:ietf:wg:oauth:2.0:oob' \ --data-urlencode 'scopes=read write follow' \ - --output ".app_sessions/$instance" \ - --create-file-mode 0600 + --output ".app_sessions/$instance" + chmod 600 ".app_sessions/$instance" fi } @@ -31,6 +32,7 @@ auth_api_get_code() { auth_api_create_client client_id=$(jq -r '.client_id' ".app_sessions/$instance") + echo "Auth link (if fail) https://$instance/oauth/authorize?client_id=$client_id&response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=read+write+follow" default_auth_browser "https://$instance/oauth/authorize?client_id=$client_id&response_type=code&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope=read+write+follow" echo 'Input token-code:' read pass @@ -49,10 +51,11 @@ auth_api_get_token() --data-urlencode "redirect_uri=urn:ietf:wg:oauth:2.0:oob" \ --data-urlencode 'scope=read write follow' \ --data-urlencode "code=$pass" | jq -r '.access_token') - echo > "$basedir"/.auth - chmod 600 "$basedir"/.auth - echo "$token" > "$basedir"/.auth + echo > .auth + chmod 600 .auth + echo "$token" > .auth } auth_api_get_token +