Skip to content

Instantly share code, notes, and snippets.

@brandur
Last active February 13, 2020 22:13
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save brandur/5845931 to your computer and use it in GitHub Desktop.
Save brandur/5845931 to your computer and use it in GitHub Desktop.
Twitter auth

Easy Twitter API OAuth 2 Access

  1. Go to your applications. Create a new one, and find the values in the Consumer Key and Consumer Secret fields.

  2. Use OAuth client information to produce an OAuth 2 access token:

    curl -i --user <consumer_key>:<consumer_secret> -X POST https://api.twitter.com/oauth2/token -d "grant_type=client_credentials"
    
    {"access_token":"<oauth2_token>","token_type":"bearer"}% 
    
  3. Then use that access token for direct API access:

    curl -i -H "Authorization: Bearer <oauth2_token>" https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name\=<screen_name>
    
    [...]
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment