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.

Source Distribution

socialauth-0.1.0.tar.gz (4.4 kB view details)

Uploaded Source

File details

Details for the file socialauth-0.1.0.tar.gz.

File metadata

  • Download URL: socialauth-0.1.0.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for socialauth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8d1d1b39d196e39a5bb8947a5a378f30a3a3513107c7d8e3ea0db9825621754c
MD5 e3bf699a1502c83bbfccf061ed152b66
BLAKE2b-256 ce15b79af8b3e845b16f3492642a147619d8c4b6364b2a6c27d1219cfbad7213

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page