An example demonstrating how to incorporated django-allauth into a django project
- Firstly clone the repo
git clone https://github.com/Jimmycheong/django_with_all_auth_example.git
cd django_with_all_auth_example
- Build a virtualenv
virtualenv env
source env/bin/activate
pip install -r requirements.txt
- Migrate to populate sqlite3 DB and run the server
python manage.py migrate
python manage.py runserver
- Go to the home page by opening:
http://localhost:8000
- Set up the required API key and secrets with the providers (Facebook API, Google API, etc.)
- To use the OAuth Apps, you have to add them into the Social Apps model within the Django admin UI.
- With Google, after you have created a client ID:
- Add Authorized JavaScript origins as your domain name (
http:localhost:8000
if running locally) - Add Authorized JavaScript origins as your domain name (
http://localhost:8000/accounts/google/login/callback/
if running locally) - Logout must be performed using a
POST
request- Django requires a CSRFToken, which will be sent as a header:
'X-CSRFToken':<csrftoken>
- It can be grabbed using this in your Javascript file:
var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
- Set the following to
True
insettings.py
file:CSRF_USE_SESSIONS
orCSRF_COOKIE_HTTPONLY
- Django requires a CSRFToken, which will be sent as a header:
References: