Search code examples
django-allauthgoogle-identity

How to integrate Google One Tap login with django-allauth?


How does one integrate the Google One Tap login experience with django-allauth?

  1. django-allauth is integrated and working great for simple username/password logins.
  2. I have Google OneTap's nicer user experience recognizing the user's authenticated Google account and offering to continue via that, sending a JWT auth token to Django.
  3. Trying to find the simplest / cleanest way to register the new user account with the OneTap token and treat them as authenticated.

Appreciate any suggestions.

Refs:


Solution

  • [Update Feb 8, 2024] Added a step by step tutorial on how to implement Google One Tap Login with Django

    Hacked something together, not as slick as one click login, (takes one extra step)

    See more details here https://twitter.com/DataLeonWei/status/1368021373151375361

    All I did was changing the google redirect URL to the existing user log-in page with Google.

    And add an additional view and replace google's data-login_uri with this view's URL.

    @csrf_exempt
    def google_one_tap_login(request):
        login_url = PUBLIC_DOMAIN_NAME + '/accounts/google/login/'
        return HttpResponseRedirect(login_url)
    

    If someone has a better solution, please let me know.

    My current hack is implemented on both sqlpad and skills.ai, please feel free to check them out and see it in action.