The repository is split into two branches:
master
-- basic authentication + social authenticationbasic
-- basic authentication only
If you do not wish to use social authentication make sure to switch to the basic
branch.
Check out the post.
-
Fork/Clone
-
Create and activate a virtual environment:
$ python3 -m venv venv && source venv/bin/activate
-
Install the requirements:
(venv)$ pip install -r requirements.txt
-
Apply the migrations:
(venv)$ python manage.py migrate
-
Enter your SMTP settings in core/settings.py file:
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" EMAIL_HOST = "<your email host>" EMAIL_USE_TLS = False EMAIL_PORT = "<your email port>" EMAIL_HOST_USER = "<your email user>" EMAIL_HOST_PASSWORD = "<your email password>" DEFAULT_FROM_EMAIL = "<your default from email>"
-
Register your app on Google and take note of your client ID and secret.
-
Enter the client IDs and secrets in core/settings.py respectively:
SOCIALACCOUNT_PROVIDERS = { "google": { "APP": { "client_id": "<your google client id>", "secret": "<your google secret>", "key": "", # leave empty }, "SCOPE": [ "profile", "email", ], "AUTH_PARAMS": { "access_type": "online", }, "VERIFIED_EMAIL": True, } }
-
Run the server:
(venv)$ python manage.py runserver
-
Your authentication API is now accessible at http://localhost:8000/api/auth/.