Command line tool to quickly authenticate a user against the Twitter API.
In some cases, you might have an app registered with the Twitter Developer website, but you don’t have the API keys you need to use them
You can quickly run twauth from any computer with npm or pnpm installed by running:
npx twauth
# or
pnpx twauth
Example output:
🐦️ Twitter API User Authorisation Tool
To get started, visit https://developer.twitter.com/ and create an API
application. Enable user authentication for OAuth 1.0a. You can enter any URL
under Callback URL, as it won’t be used by this tool.
When you’re ready, enter your API Key and Secret:
? API Key: 01234567890ABCDEFGabcdefg
? API Key Secret: 01234567890ABCDEFGabcdefg01234567890ABCDEFGabcdefg
Visit this URL in your browser to authorize your account:
https://api.twitter.com/oauth/authorize?oauth_token=123-4567890ABCDEFGHabcdefgh
? Paste the PIN here: 1234567
Access token: 123456789-ABCDEFGabcdefg0123456789ABCDEFGabcdefg01
Access secret: ABCDEFGabcdefg0123456789ABCDEFGabcdefg0123456
Now save these two values, along with your original consumer key and secret,
and use them in your Twitter app. Have fun!
You can automate twauth by setting some environment variables:
Set the OAuth 1.0a consumer key to use. Also aliased as TWITTER_API_KEY
.
Set the OAuth 1.0a consumer secret to use. Also aliased as TWITTER_API_SECRET
.
Set this to false
to disable automatically opening the user’s default browser to the Twitter authorisation page. You can also pass --no-open-browser
as a flag when running twauth.
$ TWITTER_CONSUMER_KEY=01234567890ABCDEFGabcdefg \
TWITTER_CONSUMER_SECRET=01234567890ABCDEFGabcdefg01234567890ABCDEFGabcdefg \
TWAUTH_OPEN_BROWSER=false \
npx twauth
Released and maintained by Adam Demasi (@kirb).
Based on a gist originally written by Tane Piper.
Licensed under the Apache License, version 2.0. Refer to LICENSE.md.