Before we can use the Twitter API we need to register for a developer account. 

Go to https://developer.twitter.com/en.html. You should see a page something very like:

Click apply:

Then Apply for a developer account:

Select Exploring the API and click Next.

Fill out the form that gets presented, and clock Next. Verify the information, and click Next. Agree to the terms, and click Submit Application.

A verification email will be sent to your Twitter account's email address. Respond accordingly and you'll be able to create your app.

Creating an App

To access the Twitter API, you will need to create a Twitter app. On the Twitter Developer Portal, navigate to the Projects & Apps page and click Create App.

Name your app something unique. 

After naming your app, you'll be presented with your keys and tokens. Save all 3 keys and tokens somewhere safe on your computer, such as a text file on your desktop.

Open the secrets.py file on your PyPortal and add your Twitter app's Bearer token as twitter_bearer_token.

Your secrets.py file should look like this:

# This file is where you keep secret settings, passwords, and tokens!
# If you put them in the code you risk committing that info or sharing it

secrets = {
    'ssid' : 'home ssid',
    'password' : 'my password',
    'timezone' : "America/New_York", # http://worldtimeapi.org/timezones
    'github_token' : 'fawfj23rakjnfawiefa',
    'hackaday_token' : 'h4xx0rs3kret',
    'twitter_bearer_token' : 'YOUR_SECRET_TWITTER_BEARER_TOKEN'
    }

This guide was first published on Jul 16, 2019. It was last updated on Jul 16, 2019.

This page (Twitter Auth Keys) was last updated on Aug 12, 2021.

Text editor powered by tinymce.