8000 GitHub - megalus/django-google-sso: Easily add Google Authentication to Django Admin
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

megalus/django-google-sso

Repository files navigation

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 auth 8000 entication 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":

    • For local development: http://localhost:8000/google_sso/callback/
    • For production: https://your-domain.com/google_sso/callback/
  2. 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:

Documentation

For detailed documentation, visit:

License

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

0