chrismaille/django-google-sso

Easily add Google SSO login to Django Admin

Django Google SSO

Easily integrate Google Authentication into your Django projects

PyPI Build PyPI - Python Version PyPI - Django Version License

Welcome to Django Google SSO

This library simplifies the process of authenticating users with Google in Django projects. It adds a customizable "Login with Google" button to your Django Admin login page with minimal configuration.

Why use Django Google SSO?

  • Simplicity: Adds Google authentication with minimal setup and no template modifications
  • Admin Integration: Seamlessly integrates with the Django Admin interface
  • Customizable: Works with popular Django Admin skins like Grappelli, Jazzmin, and more
  • Modern: Uses the latest Google authentication libraries
  • Secure: Follows OAuth 2.0 best practices for authentication

Quick Start

Installation

$ pip install django-google-sso

Compatibility - Python 3.11, 3.12, 3.13 - Django 4.2, 5.0, 5.1 - For Python 3.10, use version 4.x - For Python 3.9, use version 3.x - For Python 3.8, use version 2.x

Configuration

  1. Add to your settings.py:
# settings.py

INSTALLED_APPS = [
    # other django apps
    "django.contrib.messages",  # Required for auth messages
    "django_google_sso",  # Add django_google_sso
]

# Google OAuth2 credentials
GOOGLE_SSO_CLIENT_ID = "your client id here"
GOOGLE_SSO_PROJECT_ID = "your project id here"
GOOGLE_SSO_CLIENT_SECRET = "your client secret here"

# Auto-create users from these domains
GOOGLE_SSO_ALLOWABLE_DOMAINS = ["example.com"]
  1. Add the callback URL in Google Console under "Authorized Redirect URIs":
  2. For local development: http://localhost:8000/google_sso/callback/
  3. For production: https://your-domain.com/google_sso/callback/

  4. Add to your urls.py:

# urls.py

from django.urls import include, path

urlpatterns = [
    # other urlpatterns...
    path(
        "google_sso/", include("django_google_sso.urls", namespace="django_google_sso")
    ),
]
  1. Run migrations:
$ python manage.py migrate

That's it! Start Django and visit http://localhost:8000/admin/login to see the Google SSO button:

Admin Skin Compatibility

Django Google SSO works with popular Django Admin skins including: - Django Admin (default) - Grappelli - Django Jazzmin - Django Admin Interface - Django Jet Reboot - Django Unfold

Documentation

For detailed documentation, visit: - Full Documentation - Quick Setup - Google Credentials Setup - User Management - Customization - Troubleshooting

License

This project is licensed under the terms of the MIT license.

Stars
7
100.00% more than last month
Forks
5
Open Issues
1