Skip to main content

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

Metadata

Release files for django-accountkit 0.2.3

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-accountkit 0.2.3
File Size Uploaded
django-accountkit-0.2.3.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-accountkit 0.2.3
File Interpreter ABI Platform
django_accountkit-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.3 kB

Release files / django-accountkit-0.2.3.tar.gz

Download URL django-accountkit-0.2.3.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
665727291c8525fff0de935e264dd05a46c782bf3eb247342cc6e54a87533a57
BLAKE2b-256 checksum
How to use checksums
36ed8f4be437a43fab1f1587080f099d4bb5125a5dd0c5afb91725f66fe32302
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / django_accountkit-0.2.3-py3-none-any.whl

Download URL django_accountkit-0.2.3-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e75f99b62a4dce7a58599b3a415596f5201afa3c07ccf80fd5dff582d0a0c240
BLAKE2b-256 checksum
How to use checksums
e986f39e2570ec6e5a86c1d6d23f7f961c4d2c1dcb2e1a139f0072759501b765
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

1 release file

0.1.1

1 release file

0.1.0

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