Skip to content

Instantly share code, notes, and snippets.

@ademar111190
Created June 6, 2019 20:54
Show Gist options
  • Select an option

  • Save ademar111190/eb743d566004ff6c3ffdd211b6db7a39 to your computer and use it in GitHub Desktop.

Select an option

Save ademar111190/eb743d566004ff6c3ffdd211b6db7a39 to your computer and use it in GitHub Desktop.
Get the access token from twitter api
#!/bin/bash
API_KEY="$(perl -MURI::Escape -e 'print uri_escape(" <<< HERE YOUR API KEY >>> ");' "$2")"
API_SECRET="$(perl -MURI::Escape -e 'print uri_escape(" <<< HERE YOUR API SECRET >>> ");' "$2")"
CONSUMER_URL=$API_KEY:$API_SECRET
CONSUMER_URL_64=`echo -n $CONSUMER_URL | base64`
curl -s \
-H "User-Agent: My Twitter App v1.0.23" \
-H "Authorization: Basic $CONSUMER_URL_64" \
--data-urlencode grant_type=client_credentials \
--compressed \
https://api.twitter.com/oauth2/token/ | sed -e 's/[{}]/''/g' | cut -d ":" -f 3 | cut -d '"' -f 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment