diff options
author | Samuel Fadel <samuel@nihil.ws> | 2023-01-19 10:04:51 +0100 |
---|---|---|
committer | Samuel Fadel <samuel@nihil.ws> | 2023-01-19 10:04:51 +0100 |
commit | 960d8647437f7127a6de167b974b8f7aafc77130 (patch) | |
tree | 3b720f775a8e329b2ff23e077fa22335fd0473aa /bin/google-oauth2 | |
parent | 0701a5dd2e309c8d51282632e9f4b5a64a55a3e0 (diff) |
Added first few utilities0.1
Diffstat (limited to 'bin/google-oauth2')
-rwxr-xr-x | bin/google-oauth2 | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/google-oauth2 b/bin/google-oauth2 new file mode 100755 index 0000000..3ef43b9 --- /dev/null +++ b/bin/google-oauth2 @@ -0,0 +1,20 @@ +#!/bin/sh +# +# Reads client secret and client token from STDIN (slightly better than as +# args, which are public), one in each line respectively. +# +# Calls into Google's OAuth2 API with that info to retrieve an access token, +# which is output to STDOUT. +# +# CLIENT_ID is the only argument taken by this script. + +CLIENT_ID=$1 +read -r CLIENT_SECRET +read -r REFRESH_TOKEN + +curl --silent \ + --data client_id=$CLIENT_ID \ + --data client_secret=$CLIENT_SECRET \ + --data grant_type=refresh_token \ + --data refresh_token=$REFRESH_TOKEN \ + 'https://www.googleapis.com/oauth2/v4/token' | jq -r .access_token
\ No newline at end of file |