Skip to content

Latest commit

 

History

History
77 lines (53 loc) · 2.29 KB

README.md

File metadata and controls

77 lines (53 loc) · 2.29 KB

twitter-application-only-auth

A simple implementation of the Twitter Application-only authentication https://developer.twitter.com/en/docs/basics/authentication/overview/application-only that offers applications the ability to issue authenticated requests on behalf of the application itself (as opposed to on behalf of a specific user).

Tested with Python 2.7 and recent versions of 3.x

Build Status Coverage Status

Install

pip install twitter-application-only-auth

Usage

import json
from application_only_auth import Client

# The consumer secret is an example and will not work for real requests
# To register an app visit https://dev.twitter.com/apps/new
CONSUMER_KEY = "xvz1evFS4wEEPTGEFPHBog"
CONSUMER_SECRET = "L8qq9PZyRg6ieKGEKhZolGC0vJWLw8iEJ88DRdyOg"

client = Client(CONSUMER_KEY, CONSUMER_SECRET)

# Pretty print of tweet payload
tweet = client.request("https://api.twitter.com/1.1/statuses/show.json?id=316683059296624640")
print(json.dumps(tweet, sort_keys=True, indent=4, separators=(",", ":")))

# Show rate limit status for this application
status = client.rate_limit_status()
print(status["resources"]["search"])

Real-World use cases

Development

To contribute to this project or to test this library locally you'll need to install these dependencies:

python3 -m venv venv # for example on a virtual environment
source venv/bin/activate
pip install -r requirements-test.txt
pip install black

and you can validate your changes running:

python -m pytest --verbose
black . --line-length=120 --check --diff

Authors and contributors