An example of how to create a Django web app with SSO support using oAuth.
- Download or clone the source code from the website:
git clone git@github.com:kuan51/djcal.git
- Create a python3 virtual environment:
python3 -m venv [name_of_your_virtual_environment]
- Install dependencies:
pip install -r requirements.txt
- Migrate databases and applications:
python ./manage.py migrate
- Sync databases:
python ./manage.py migrate --run-syncdb
- Create admin user:
python ./manage.py createsuperuser
- Run server:
python ./manage.py runserver
- Browse to
localhost:8000
and login with the username and password from step 6.
You will need to repeat this guide for each social media application you have.
- Browse to
localhost:8000/admin
and login with your admin user. - Go to Social Applications > Add Social Application
- Login to your oAuth account (i.e. Github, Google, Reddit, etc) and find your client id and secret.
- Select the oAuth app you want to configure from the dropdown and assign a name.
- Enter the client id and secret from step 3 and save.
- Go back to the main admin page:
localhost:8000
- Go to Sites > Click on the example site name.
- Change the domain name to localhost and save.
- Browse to Social Applications > Click on the name of your oAuth account
- Under sites, add localhost to the right column "Chosen Sites" and save.
- Logout and test the oAuth login, it should automatically create a user based on the username from the oauth application. It only requests your username and email, and no other information.