Skip to main content

A framework- and backend-independent social login provider.

Project description

Python Social Auth

https://travis-ci.org/emilyhorsman/socialauth.svg?branch=master https://coveralls.io/repos/github/emilyhorsman/socialauth/badge.svg?branch=master https://img.shields.io/pypi/v/socialauth.svg https://img.shields.io/badge/python-%E2%89%A5%203.3-blue.svg https://img.shields.io/badge/code%20of%20conduct-v1.3.0-4C1161.svg https://img.shields.io/pypi/l/socialauth.svg

A generic library to authenticate with login providers such as Twitter and Facebook.

$ pip install socialauth

Flask Example

@app.route('/whoami')
def whoami():
    res = jwt.decode(request.cookies.get('jwt'), current_app.secret_key)
    return res.get('user_id')


@app.route('/auth/<provider>')
def authenticate(provider):
    res = socialauth.http_get_provider(
        provider,
        request.base_url,
        request.args,
        current_app.secret_key,
        request.cookies.get('jwt')
    )

    if res.get('status') == 302:
        resp = make_response(redirect(res.get('redirect')))
        if res.get('set_token_cookie') is not None:
            resp.set_cookie('jwt', res.get('set_token_cookie'))

        return resp

    if res.get('status') == 200:
        resp = make_response(jsonify({ 'status': 'success' }))
        resp.set_cookie('jwt', res.get('set_token_cookie'))
        return resp

    abort(400)

Current Providers

  • Twitter
  • Facebook

Why?

Many social authentication solutions exist. I wanted something that didn’t have strong ties to an HTTP framework or storage backend. Preferably, I didn’t want something that dealt with a storage backend at all. This library uses JSON web tokens instead of sessions to deal with intermediate information in the OAuth flow (such as a token secret).

Project details


Download files

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

Files for socialauth, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size socialauth-0.1.0.tar.gz (4.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page