Skip to main content

Simplified OAuth + OpenID Connect for authentication via Google.

googleauth used to be REALLY simple, but then Google decided to get rid of their OpenID service. Boooo Google. googleauth has been migrated to OAuth 2.0 + OpenID Connect, which isn’t quite as great because it takes a bit more configuration to get going.

googleauth was built to provide an easy way to add authentication against a Google Apps for Business domain, ideally for an individual organization. This package is not the best option if you are looking for a general social auth solution. Check out python-social-auth instead.

Getting things set up on Google

  1. Log in to the Google API Console.

  2. Open an existing project or create a new one if needed.

  3. Under the APIS & AUTH menu item, click APIs.

  4. Turn on the Google+ API.

  5. Under the APIS & AUTH menu item, click Credentials.

  6. Click the Create new Client ID button.

  7. Select Web application for application type, add your domain as the JavaScript origin, and add the full domain and path to the OAuth callback (see below for how to find this URL). Click the Create Client ID button to finish.

  8. You’re going to need the Client ID and Client secret values in Django settings, so keep this window open or copy them for later.

Callback URL

The callback URL is constructed from your preferred URL scheme, the domain at which your site is hosted, and the path where you mount the googleauth URL config in Django.

Let’s assume you are using HTTPS and have mounted the googleauth URL config at the root URL. Your callback URL would look something like:

https://<your-domain>/callback/

Okay, now let’s assume you are using HTTP and have mounted the googleauth URL config under /accounts/:

http://<your-domain>/accounts/callback/

Django Setup

Settings and configuration

The following settings should be placed in settings.py.

Add to INSTALLED_APPS:

INSTALLED_APPS = (
    ...
    'googleauth',
    ...
)

Add to AUTHENTICATION_BACKENDS:

AUTHENTICATION_BACKENDS = (
    'googleauth.backends.GoogleAuthBackend',
    ...
)

Required settings:

# client ID from the Google Developer Console
GOOGLEAUTH_CLIENT_ID = ''

# client secret from the Google Developer Console
GOOGLEAUTH_CLIENT_SECRET = ''

# your app's domain, used to construct callback URLs
GOOGLEAUTH_CALLBACK_DOMAIN = ''

Optional settings:

# callback URL uses HTTPS (your side, not Google), default True
GOOGLEAUTH_USE_HTTPS = True

# restrict to the given Google Apps domain, default None
GOOGLEAUTH_APPS_DOMAIN = ''

# get user's name, default True (extra HTTP request)
GOOGLEAUTH_GET_PROFILE = True

# sets value of user.is_staff for new users, default False
GOOGLEAUTH_IS_STAFF = False

# list of default group names to assign to new users
GOOGLEAUTH_GROUPS = []

URL routes

Add URL config:

urlpatterns = patterns('',
    ...
    (r'^auth/', include('googleauth.urls')),
    ...
)

googleauth doesn’t need to be mounted under /auth/, it can go anywhere. Place it where you see fit for your specific app.

Release files for django-googleauth-ng 2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-googleauth-ng 2.5
File Size Uploaded
django-googleauth-ng-2.5.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-googleauth-ng 2.5
File Interpreter ABI Platform
django_googleauth_ng-2.5-py2-none-any.whl Python 2 none any Details

Total release size: 13.0 kB

Release files / django-googleauth-ng-2.5.tar.gz

Download URL django-googleauth-ng-2.5.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
e11490a1693ce091cf30a94e663c987db74641fbc4ebf515015d258965d93254
BLAKE2b-256 checksum
How to use checksums
aac077ad309bd5349dc5784915bfef99389fa7a91fb783cd076972381957bc2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / django_googleauth_ng-2.5-py2-none-any.whl

Download URL django_googleauth_ng-2.5-py2-none-any.whl
Size 8.2 kB
Tags Python 2
SHA-256 checksum
How to use checksums
c04803c69a60455e3624b29b070b67007b9a700aa8c4ae9f58ee0b428ec04de9
BLAKE2b-256 checksum
How to use checksums
45cef71428f16e6c302ce7e483e00eb4dcc983d06ee39b78ae76f96594d2becb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

2.5 This release

2 release files

2.4

2 release files

2.3

2 release files

2.2

2 release files

2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page