34 lines
650 B
Bash
Executable File
34 lines
650 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -o errexit
|
|
|
|
main() {
|
|
local single_use_token="${1}"
|
|
|
|
[[ "${single_use_token}" ]] || {
|
|
echo "Missing single use token arg"
|
|
exit 1
|
|
}
|
|
|
|
[[ "${OOM_CLIENT_ID}" ]] || {
|
|
echo "Missing \$OOM_CLIENT_ID"
|
|
exit 1
|
|
}
|
|
|
|
[[ "${OOM_CLIENT_SECRET}" ]] || {
|
|
echo "Missing \$OOM_CLIENT_SECRET"
|
|
exit 1
|
|
}
|
|
|
|
curl \
|
|
-X POST \
|
|
-sSL \
|
|
-d "client_id=${OOM_CLIENT_ID}" \
|
|
-d "code=${single_use_token}" \
|
|
-d "client_secret=${OOM_CLIENT_SECRET}" \
|
|
-d 'redirect_uri=urn:ietf:wg:oauth:2.0:oob' \
|
|
-d 'grant_type=authorization_code' \
|
|
'https://accounts.google.com/o/oauth2/token'
|
|
}
|
|
|
|
main "$@"
|