Skip to main content

django-facebook-auth

https://travis-ci.org/pozytywnie/django-facebook-auth.svg

A stable Facebook authentication backend for Django >= 1.4.

Starting from version 3.6.0 Django 1.7 is supported. South migrations are move to south_migrations so you need South 1.0 or newer to use them.

Requires Celery for background token operations.

Installation

Package

django-facebook-auth can be installed as a normal Python package.

Example installation for pip:

$ pip install django-facebook-auth

Configuration

Celery

This project requires working Celery integration. In case you are new to Celery, the First steps with Django tutorial will help you to hit the ground running.

settings.py

Set USE_TZ = True

Add facebook_auth to INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'facebook_auth',
    ...
)

Add authentication backends to AUTHENTICATION_BACKENDS:

AUTHENTICATION_BACKENDS = (
    ...
    'facebook_auth.backends.FacebookBackend',
    'facebook_auth.backends.FacebookJavascriptBackend',
    ...
)

Set necessary Facebook properties:

FACEBOOK_CANVAS_URL = 'http://pozytywnie.pl/'  # root of your domain
FACEBOOK_APP_ID = '1234567890'
FACEBOOK_APP_SECRET = '91162629d258a876ee994e9233b2ad87'

Usage

The authentication flow is very straightforward:

  1. Redirect your user to Facebook OAuth endpoint using redirect_uri prepared with the help of this library.

    First in your view or context processor prepare the necessary parameters for the Facebook OAuth endpoint:

    from facebook_auth.urls import redirect_uri
    
    def login(request):
        ...
        context.update({
            'redirect_uri': redirect_uri('/login/success', '/login/fail'),
            'client_id': settings.FACEBOOK_APP_ID,
            'scope': 'email'
        })
        ...

    And embed the link in your template:

    <a href="https://www.facebook.com/dialog/oauth?client_id={{ client_id }}&amp;scope={{ scope }}&amp;redirect_uri={{ redirect_uri }}">Login using Facebook</a>
  2. User is redirected back to django-facebook-auth authentication handler, which either authenticates the user or refuses to do so.

    Prepare a separate view for each scenario.

  3. A best token for authenticated user is negotiated with Facebook in the background, using your Celery worker.

Release files for django-facebook-auth-tmp 3.9.0.1

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

Source distribution (sdist)

Source distribution for django-facebook-auth-tmp 3.9.0.1
File Size Uploaded
django-facebook-auth-tmp-3.9.0.1.tar.gz 18.6 kB Details

Release files / django-facebook-auth-tmp-3.9.0.1.tar.gz

Download URL django-facebook-auth-tmp-3.9.0.1.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
eb1e6ff0ac6dd20590ba6c4448be625efdcd365b32d8d364e15c1351fa2edd08
BLAKE2b-256 checksum
How to use checksums
9b17fbaf02614c1fd2f85c004cd4b974e45eb29b87f4a5b47ebe24a893ec9c2f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

3.9.0.1 This release

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