DEV Community

Cover image for How i implemented google oauth in my flask application with supabase
Calum
Calum

Posted on

How i implemented google oauth in my flask application with supabase

Authentication is often a pain point for users. Nobody wants to create yet another account and remember another password. That's why i decided to implement google oauth for my flask based pdf processing application, revisepdf.

Why google oauth?

  • One click authentication
  • No password management for users
  • Higher conversion rates
  • Reduced signup abandonment

Setting up with supabase

Supabase made implementing google oauth surprisingly straightforward:

  1. Created a project in google cloud console and set up oauth credentials
  2. Added these credentials to supabase's authentication providers
  3. Implemented the authentication flow in flask

The implementation

Here's the core code for initiating the google sign
flow:


python
@auth_bp.route('/google-signin')
def google_signin():
    """google oauth flow."""
    redirect_url=url_for('auth.google_callback',_external=True)
    return redirect(supabase.auth.sign_in_with_oauth({
        "provider": "google",
        "options":{"redirect_to": redirect_url}
    }).url)
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
revisepdf profile image
Calum
Collapse
 
revisepdf profile image
Calum

if it doesn't work let me know asap lmao !!