This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Minimalist and framework independent OAuth(1 & 2) consumers

Project Description


For the latest source, discussions, etc., please visit the GitHub repository


Minimalist and framework independent package that provides common OAuth (1 & 2) consumers (or the ability to easily add more).

  • Unifies OAuth1 and OAuth2 flows into one easy and clear dance
  • Normalises providers’ profiles data
  • Normalises OAuth1 & 2 tokens for storage/restoration
  • Based on oauthlib and requests


pip install uniauth


Retrieve a token:

from uniauth import Bitbucket, GitHub

# Use an OAuth2 client
client = GitHub(client_id="****************", client_secret="****************", scope=None)

# Or an OAuth1 client
client = Bitbucket(client_id="****************", client_secret="****************")

# Provides a unified flow for both OAuth1 & OAuth2
oauth_dance =, "")

# 'stash' allows to complete the oauth dance over multiple requests (by maintaining OAuth1's request token or OAuth2's state)
# It can be anything as long as it implements __setattr__(key, value) and pop(key, default)
# e.g.:
#     stash = request.session
# Or
#     stash = {}

# Redirect your user to:

# Get the access token using the absolute url the povider redirected your user to:
normalised_token = oauth_dance.get_access_token(callback_url)
# {"token": "**********", "extra": "**********", "expires_at": None, "scope": None}

# The token is also stored in the client state

Restore a token:

# OAuth2 client
client = GitHub(client_id="****************", client_secret="****************", scope=None, token=normalised_token)

# or OAuth1 client
client = Bitbucket(client_id="****************", client_secret="****************", token=normalised_token)


Request any resource:

# client.request has a similar signature to requests.request but with an optional method (it uses "GET" by default)
response = client.request(url_to_resource)

# response is an instance of requests.Response

data = response.json()

That’s it.

Available Consumers


Use uniauth.Bitbucket


Use uniauth.Facebook


Use uniauth.GitHub


Use uniauth.Google


Use uniauth.LinkedIn

Contribute More

It’s easy to add more consumers:

from uniauth.base import ProfileMixin
from uniauth.oauth2 import OAuth2Consumer

class MyProviderName(ProfileMixin, OAuth2Consumer):
    authorization_url = ""
    access_token_url = ""
    profile_url = ""

    def normalize_profile_data(self, data):
        # transform provider's format into normalised format
        return {"uid": data.get("id"),
                "email": data.get("email_address"),
                "username": data.get("login"),
                "first_name": data.get("given_name"),
                "last_name": data.get("family_name"),
                "gender": data.get("sex"),
                "birthdate": data.get("dob"),
                "avatar_url": data.get("picture"),
                "is_verified": data.get("verified")}

Running Tests

Get a copy of the repository:

git clone .

Install tox:

pip install tox

Run the tests:



All contributions and comments are welcome.

Change Log


  • Cast default provider name to unicode
  • Fix resource request extra params not used


  • Initial
Release History

Release History

This version
History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
uniauth-0.0.2-py2.py3-none-any.whl (11.8 kB) Copy SHA256 Checksum SHA256 py2.py3 Wheel Jun 22, 2015
uniauth-0.0.2.tar.gz (10.1 kB) Copy SHA256 Checksum SHA256 Source Jun 22, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting