Skip to main content

Command Palette

Search for a command to run...

How to implement Google Authentication with Firebase for Flutter Desktop Apps

Implement Google authentication into your application using Firebase

Published
2 min read
How to implement Google Authentication with Firebase for Flutter Desktop Apps
C

Unless you’re a Multimillion or a Billion dollar company, you probably don’t have a multimillion-dollar ad budget or professional Spinners. Your product needs to stand out on its own merits like App Quality, Performance, UI design, and User Experience. Most companies don't care about you, your product, and your vision or dreams. They don't give a damn about either their work helped you to get more business, revenue, users, or solving a problem. That's where CANOPAS comes into the picture. Whether you have a GREAT IDEA and you want to turn it into a DIGITAL PRODUCT. OR You need a team that can turn your NIGHTMARES into SWEET DREAMS again by improving your existing product. We help Entrepreneurs, startups, and small companies to bring their IDEA to LIFE by developing digital products for their business. We prefer using Agile and Scrum principles in project management for flexibility and rapid review cycles. We are not bound by technology. We will learn new technology if it significantly improves the performance of your app. We will solve your tech-related problems even though we are not THE EXPERT in it. And we've done it multiple times in the last 7 years. In the last seven years, we helped... A STARTUP to expand its users from 2500 to over 100000 by developing mobile apps for them. An enterprise client to redevelop their app that has 1M+ monthly paid users and 10M+ app downloads. Another enterprise client(5M+ app downloads in each store) to fix bugs and broken parts in the app and as a result, they had over 98% crash-free users. We offer a 100% MONEY BACK GUARANTEE if you don't like our work. No questions asked. Visit : https://canopas.com/blog

Integrating Google sign-in with a flutter desktop app is different from mobile apps because a popular flutter package named google_sign_in doesn't support desktop platforms yet.

This article will guide you on implementing Sign-in with Google for your Flutter desktop apps using OAuth2.0 protocol and desktop browser.

Here's what the auth flow looks like:

  • User clicks on the “Sign in with Google” button in our app, which redirects them to Google’s 2.0 authorization endpoint.

  • The user is prompted to log in to their Google account and grant permission for our app to access their data.

  • If the user grants permission, Google redirects the browser to the redirect URI specified in the initial request, along with an authorization code.

  • Our app sends a request to Google’s OAuth 2.0 token endpoint, along with the authorization code for an access token.

  • Google returns an access token, which our app can use to authenticate requests to the corresponding Google service’s API.

  • Our app can now make authorized requests on behalf of the user until the access token expires or is revoked by the user.

Table of Contents:

  • Prerequisites
  1. Set up the firebase project

  2. Configure the OAuth client

  3. Set up the flutter Project

  • Let's Get Started
  1. Add Dependencies

  2. Import the dependencies

  3. Getting Credentials

  4. Obtaining OAuth2 Client and Access Token

  5. Redirecting to the Authorization URL

  6. Get Authorization Code from the request

  7. Creating AuthCredentials for firebase authentication

  8. Signing a user with AuthCredentials

  9. Implementing Firebase Sign-out

For a step by step implementation guide, check out our canopas blog.