How to Obtain the Twitter API’s Key and Token — First step to building a Twitter bot
This article will show you the steps to getting access to Twitter by API, including how to apply for the API and get the tokens of your Twitter:
API Key
API Key Secret
Bearer Token
Access Token
Access Token Secret
Client ID
Client Secret
These tokens can be used in Python or other languages to log in to your Twitter bot.
1) register a Twitter developer account
① First, you need a Twitter account with a verified phone number.
② sign up for the developer account here:
2) create a project and an App
① click the “Create Project” button and fill in the forms.
② copy the “API Key”, “API Key Secret” and “Bearer Token” from the last page.
3) set up the App
① click the “App Settings” button on the above page.
② click the “Set up” button.
③ check the box of “Read and write and Direct message” and “Web App, Automated App or Bot”
④ fill in the “App info” forms and click the “Save” button.
⑤ copy your “Client ID” and “Client Secret”.
4) get the tokens of API
① click the “Keys and token” label of the APP.
② click the “Generate” button of “Acess Token and Secret”.
③ copy your “Access Token” and “Access Token Secret”.
5) regenerate the tokens of API
You can see all your tokens on the page named “Keys and tokens”.
To be specific, there are 7 strings you need to copy:
API Key
API Key Secret
Bearer Token
Access Token
Access Token Secret
Client ID
Client Secret
These are the account and password of your Twitter bot. Save them in a safe place.
Sometimes, the token you generate for the first time doesn’t work. When there is an error, you can regenerate all the tokens and try it again. Just click the “Regenerate” button.