Skip to main content
https://travis-ci.org/jbn/brittle_wit_core.svg?branch=master https://ci.appveyor.com/api/projects/status/69kj3prrrieyp8q2/branch/master?svg=true https://coveralls.io/repos/github/jbn/brittle_wit_core/badge.svg?branch=master https://img.shields.io/pypi/v/brittle_wit_core.svg https://img.shields.io/badge/license-MIT-blue.svg https://img.shields.io/pypi/pyversions/brittle_wit_core.svg

What is this?

This package contains the core of brittle_wit, a twitter lib for python. It works with Python 2.7, whereas brittle_wit does not. It’s extracted from the main library so that you can reuse this core code for authentication flows (e.g. on GAE).

Sample Authentication Flow with requests

from requests import request
from brittle_wit_core import (AppCredentials,
                              obtain_request_token,
                              extract_access_token,
                              redirect_url,
                              obtain_access_token,
                              extract_request_token)

# Loads via TWITTER_APP_KEY, TWITTER_APP_SECRET environmental variables.
APP_CRED = AppCredentials.load_from_env()

# Get an access token.
twitter_req, headers = obtain_request_token(APP_CRED)
resp = request(twitter_req.method,
               twitter_req.url,
               params=twitter_req.params,
               headers=headers)
oauth_token, oauth_secret = extract_request_token(resp.status_code,
                                                  resp.content.decode('utf8'))

# Redirect the user to a PIN page.
url = redirect_url(oauth_token)
print(url)
pin = input("PIN: ").strip()


# Turn their pin response into an access token.
twitter_req, headers = obtain_access_token(APP_CRED, oauth_token, pin)

resp = request(twitter_req.method,
               twitter_req.url,
               params=twitter_req.params,
               headers=headers)
d = extract_access_token(resp.status_code, resp.content.decode('utf8'))
print(d)

Metadata

Release files for brittle_wit_core 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for brittle_wit_core 0.0.4
File Size Uploaded
brittle_wit_core-0.0.4.tar.gz 13.2 kB Details

Release files / brittle_wit_core-0.0.4.tar.gz

Download URL brittle_wit_core-0.0.4.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d75ba61c3d722967b3549a6157516d08581c4b0a59a73e67ef4fac254c044614
BLAKE2b-256 checksum
How to use checksums
73b075a86c7d1b2f59071c6e3816c82604ae5b02999f82c37914ba869634bad0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.4 This release

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page