Created
June 6, 2019 20:54
-
-
Save ademar111190/eb743d566004ff6c3ffdd211b6db7a39 to your computer and use it in GitHub Desktop.
Get the access token from twitter api
This file contains hidden or 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
| #!/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