Skip to main content

Facebook accountkit support for Django

Project description

django-accountkit

Using Facebook accountkit with Django https://developers.facebook.com/products/account-creation

PyPI version Join the community on Spectrum

Overview

This package enables the use of Facebook Accountkit with Django authentication

If you want to know more about Facebook Accountkit, check out the following resources

Requirements

  • Python (>= 2.7 and <= 3.7)
  • Django (>=1.11)

Installation

Installation is easy using pip

pip install django-accountkit

Then to add Django Accountkit to your project add the app accountkitlogin to your INSTALLED_APPS.

Now add the following settings in your settings.py file

APP_ID = <Accountkit App ID>
ACCOUNT_KIT_APP_SECRET = <Accountkit App Secret>
ACCOUNT_KIT_VERSION = "v1.0"
ACCOUNT_KIT_SUCCESS_REDIRECT = <The URL for the page where user will land after authenticating> (Please Use absolute path only)
#Example ACCOUNT_KIT_SUCCESS_REDIRECT = "http://localhost:8000/success"

Then add the following in your settings.py file

AUTHENTICATION_BACKENDS = (
	'accountkitlogin.authenticate.GetOrCreateUser',
)

Using Accountkitlogin

View

To use Accountkit to authenticate your users import from accountkitlogin.views import login_status

Then in your view use login_status

@csrf_exempt
def success_page(request):
	context = login_status(request)

Note that csrf exempt is required because Facebook Accountkit will redirect the user to your success page url and this might throw a cross origin error

The login_status function accepts the request as parameter and returns a dictionary with

  • Key 'authenticated' True or False
  • Key 'message' A message related to whether the user is authenticated or not
  • Key 'user' Returns a user instance when 'authenticated' is True

Add the view to your urls.py file for the success_page url which you defined in ACCOUNT_KIT_SUCCESS_REDIRECT setting

Template Tags

Add {% load accountkit %} at the starting of your template and add the following template tags to your file where you want to display the login buttons

  1. Add (% accountkitjs %} inside your <head></head> tag
  2. Add {% accountkitform %} inside your <body></body> tag
  3. Add {% smslogin %} and/or {% emaillogin %} anywhere in you body section where you want to display your login buttons. Both these tags accept two parameters className and text where you can add your custom css classes and the text to display on the button. Example {% emaillogin "button" "Use the email" %}

Notes

Contribute

Please contribute to this repositiory :)

Author

This is project is inspired by

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

django-accountkit-0.2.2.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_accountkit-0.2.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file django-accountkit-0.2.2.tar.gz.

File metadata

  • Download URL: django-accountkit-0.2.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for django-accountkit-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d1e513c9d72a7137a1568d77cc5b52bc25a5e8456aa3e7e07f443fc27ff5a7f1
MD5 bdf2390a9ce339b877091760d34c1755
BLAKE2b-256 1cd5076c259f41eb1749112d0ec0c2ecd5e0e5d6d6b90ebf437797daee922ccb

See more details on using hashes here.

File details

Details for the file django_accountkit-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: django_accountkit-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.4

File hashes

Hashes for django_accountkit-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 22923b7a6d16124fa94b1a52e7fb9168bbb107b4bb6296d2987c0a1e07e59671
MD5 2b28f9d90f7adc7bc22b0bffa5fb7c0c
BLAKE2b-256 b01156acb46443bff0467853fbf3533bfc7518b611166453a64b93f2e66add59

See more details on using hashes here.

Supported by

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