Monday, September 5, 2016

how to generate a twitter (bearer) key with curl to use the twitter api


First you need to craete a twitter application (https://apps.twitter.com) and generate a consumer (api) key and consumer (api) secret.


With this key and secret, you must call https://api.twitter.com//oauth2/ once to generate the bearer key. 
curl -XPOST https://api.twitter.com//oauth/token -u apikey:api-secret --data "grant_type=client_credentials"

With the access token from the response you can access the Twitter APIs


https://dev.twitter.com/oauth/application-only

and... just to save your time. the keys in the example above will not work ;)