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

An OAuth based authentication blueprint for flask. Easy to extend and override

Project Description

An OAuth based authentication blueprint for flask. Easy to extend and

.. image::

.. image:: :target:


Based on ``example/gae`` codebase with secret ````
provided for proper OAuth providers configuration.


There is `Flask-Social`_ extension, but is painfully interconnected and
to change anything you basically have to fork and rewrite portions of

Not to mention that it requires POST request on social login endpoints.
I hate that I need to write an inline forms to create a login button.

How it’s any better?

This blueprint plays nicely with `Flask-Security`_ and it’s easily
overridable without forking everything, it’s `plain simple OOP`_ not that
`module based provider`_ `function search crap`_.

To extend it just write a provider class anywhere you want, and setup
it’s client id and secret in the flask settings providing an import path
like this:

.. code:: python

"flask_social_blueprint.providers.Facebook": {
# App ID
'consumer_key': '197…',
# App Secret
'consumer_secret': 'c956c1…'
"flask_social_blueprint.providers.Twitter": {
# Your access token from API Keys tab
'consumer_key': 'bkp…',
# access token secret
'consumer_secret': 'pHUx…'
"flask_social_blueprint.providers.Google": {
# Client ID
'consumer_key': '797…',
# Client secret
'consumer_secret': 'bDG…'
"flask_social_blueprint.providers.Github": {
# Client ID
'consumer_key': '6f6…',
# Client Secret
'consumer_secret': '1a9…'


What’s missing?

This is just authentication blueprint there is no templates, models and
stuff that you would want to customize yourself.

What to do more?

1. More providers
2. Make Flask-Security dependency optional


The core of this module has no GUI, but examples have a nice login
and profile page to show it it works. Checkout the `demo`_.

.. image::
:alt: Flask social blueprint login form example
:align: center

.. image::
:alt: Flask social blueprint user profile example
:align: center

The example has a working model and templates, has a bunch of
dependencies like `Flask-SLQAlchemy`_, you can take it as a wire frame
modify and build your app with that.

Examples are made from some existing apps, they may contain more stuff
that’s really needed to showcase this module. When in trouble just ask

Or just drop in this solution inside your working Flask app. It should
not create any conflicts with existing stuff. You maybe required to
write an adapter for your User model and SocialConnection model (or
similar) but that’s 3 functions for the adapter. All User model
requirements come from `Flask-security`_.

1. for `SQLAlchemy <example/sqla/>`_
2. for `Google App Engine <example/gae/>`_
3. for `MongoDB <example/mongodb/README.rst>`_

Development environment with Vagrant

You can always use our `vagrant`_. It should set up everything needed for tests or
development. This should set up everything you need:

.. code:: sh

vagrant up --provision

The code will be kept in ``/vagrant/`` directory.
You have will get 3 python virtual enviroments setup:

* gae – for gae example
* sqla – for sqla example
* mongodb – for mongodb example

Activate one of them using `virtualenvwrapper`_. For example to activate mongodb:

.. code:: sh

workon mongodb
python /vagrant/example/mongodb/

Google App Engine example have to be run little bit different,
it needs GAE development server layer wrapping Flask.

.. code:: sh

workon gae
python ~/google_appengine/ --host --port 5055 /vagrant/example/gae/

When you develope with and without vagrant because please remeber that `flask-social-blueprint/example/gae/lib/`
will be shared between machines, it may cause problems.

Setup OAuth with different providers

This blueprint needs client id's and secrets provided by social services you
want to integrate with, here's where you setup them.

In examples we use URL to overcome limitations
posed on `localhost` and `` when setting up integrations.
The URL is guaranteed to be valid and may be used by
anyone in demos and documentation. Just map `` to ``
and you're good to go.

Callback URLs use the name of the provider at the end.
Obtain client ids and secrets from OAuth providers using
main URL and callbacks URLS like these:



Create new application here:


1. Create new project here:
2. In APIs & auth > Credentials create Client ID
3. Update consent screen details, at least product name, home page and email address
4. Enable Google+ API


Create new application here:


Create new application here:

Setup `Valid OAuth redirect URIs` in Settings > Advanced > Security

.. _Flask-Social:
.. _Flask-Security:
.. _Flask-SLQAlchemy:
.. _demo:
.. _plain simple OOP: src/flask_social_blueprint/
.. _module based provider:
.. _function search crap:
.. _virtualenvwrapper:
.. _vagrant:
Release History

Release History

This version
History Node


History Node


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 (16.5 kB) Copy SHA256 Checksum SHA256 Source Dec 25, 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