Created
August 29, 2019 22:53
-
-
Save iamdaniele/a2380f633c48b7dcb7ad88f8ec4fc09b to your computer and use it in GitHub Desktop.
Get Bearer Token (shell function)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bearer_token () { | |
local CONSUMER_API=$1 | |
local CONSUMER_SECRET=$2 | |
| |
if [ -z "$CONSUMER_API" ] || [ -z "$CONSUMER_SECRET" ] ; then | |
echo "Usage: ${FUNCNAME[0]} <consumer_api_key> <consumer_secret>" | |
return 1 | |
fi | |
| |
curl -s -XPOST -H "Authorization: Basic $(echo -n $CONSUMER_API:$CONSUMER_SECRET | base64)" -H "Content-type: application/x-www-form-urlencoded; charset: utf-8" -d "grant_type=client_credentials" https://api.twitter.com/oauth2/token | jq -r .access_token | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment