You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
box-o-sand/youtube-api-poking/exchange-auth-code

34 lines
650 B

#!/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 "$@"