To get a Consumer Key (API Key) and Consumer Secret (API Secret), you first need a developer account on Twitter. Here you can apply for one:
Once you have a developer account, follow these four steps:
- Go to the page https://developer.twitter.com/en/apps and click on Create an app
- Fill in all required fields
- When you are in the detail overview of the app, click on Keys and tokens at the top of the app navigation.
- Then you should see in the section Consumer API keys both required keys.
Tip: When copying from the Consumer Key (API Key) and Consumer Secret (API Secret), be careful not to copy them with a space at the end. It's already happened to some (including me).