Skip to main content

This project help with Google Authentication flow when you prefer API approach. It uses existing User model in your database and no other tables are created. It also lets you modify parameters based on your business logic and current authentication flow.

Quick Start

  1. Add “google_auth” to your INSTALLED_APPS setting like this:

INSTALLED_APPS = [
    ...
    'google_auth',
]
  1. Add “email” field to your user table if it doesn’t already exist.

  2. (OPTIONAL) To have user retrieved info saved in your add these fields to your user table:

    • given_name

    • family_name

  3. Add a new url to your projects url.py like this:

re_path('auth/url', views.AuthURL.as_view(), name="auth_url")
  1. Create a new view which is a subclass of ‘AuthCallback’ like this:

class CallbackView(AuthCallback):
   def get(self, request):
      user = super(CallbackView, self).get(request)
      # create new token and authenticate user. Return token and required parameters here``
  1. Add another new url to your projects url.py like this:

re_path('auth/calback', views.CallbackView.as_view(), name="auth_calback_url")

Configuration parameter

  • AUTH_USER_MODEL: Authentication user table in your models

  • CLIENT_ID: Retrieved from Google console

  • CLIENT_SECRET: Retrieved from Google console

  • REDIRECT_URI: Redirect url same as redirect url in google console (Usually it should route to your front-end url)

  • VALIDATE_STATE: (OPTIONAL) state is a server side generated security feature suggested by google. It will be saved in session. default value it True. If set to False it will bypass this security check.

  • SET_REGISTER_USER_FIELD: (OPTIONAL) If you want to set some value in User table after login/register process is successful, you can set it here. In example below, we set user verified field to True when login/register process is successful:

    SET_REGISTER_USER_FIELD = {
      "verified": True
    }
  • USER_INFO_REQUEST_URI: (OPTIONAL) Google verification url. Should be fine with default value.

URLs Flow

  1. First call ‘auth/url’ by POST(Empty body) or GET Method.

    • GET method will return generated URL in JSON response. Your front end should redirect to this URL.

    • POST method will return 302 status code with redirect url.

  2. After redirecting to received URL from step 1, user can verify from Google. If verification is successful Google will call your redirect_uri.

  3. when redirect_uri is called your frontend should call the Callback url you already created (step 6 in Quick start).

    • IMPORTANT: You must add all query params received from Google in this step to ‘auth/callback’ as query params.

Metadata

Release files for django-google-oauth-rest 1.0

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-google-oauth-rest 1.0
File Size Uploaded Provenance
django-google-oauth-rest-1.0.tar.gz 5.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-google-oauth-rest 1.0
File Interpreter ABI Platform
django_google_oauth_rest-1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / django-google-oauth-rest-1.0.tar.gz

Download URL django-google-oauth-rest-1.0.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9f0c029bede9a05dbae6d7d85eaa04bc10ce78620cfdd6b4c761339432669c53
BLAKE2b-256 checksum
How to use checksums
7274838d07ea8a3fb097b7d95e89cc15312b23b1c96d4366555c09db985fc532
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.4

Release files / django_google_oauth_rest-1.0-py3-none-any.whl

Download URL django_google_oauth_rest-1.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce8eb9f425c872d510a47e04faeea318b499232b5e64b277d3ad6d0eb5357c20
BLAKE2b-256 checksum
How to use checksums
134424fab0020469e095c9de76bec07d142cd2b64dfbdbd02a576b87e38bccca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.4

Security for django-google-oauth-rest 1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0 This release

2 release files No provenance

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