fz_google_oauth2 0.0.2 copy "fz_google_oauth2: ^0.0.2" to clipboard
fz_google_oauth2: ^0.0.2 copied to clipboard

A Flutter plugin for Google OAuth.

🎬 fz_google_oauth2

A Flutter package for Google OAuth2 authentication to get access to Google APIs , login And. contain Custom Interceptors For Refresh Token

πŸ“– Table of Contents #

Screens #

Screen 1 Screen 2

Features #

  • πŸš€ Login And Get Access To Google APIs
  • πŸš€ Custom Interceptors For Refresh Token
  • πŸš€ Complete Google OAuth2 Flow

Getting Started #

  1. Add dependency: In your pubspec.yaml:
dependencies:
  fz_google_oauth2: ^0.0.2
  1. Install Package In your project:
flutter pub get
  1. Android Configuration: In your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" /> 

in /android/app/build.gradle

minSdk = 24
// Prefered 
compileSdk = 34
  1. iOS Configuration: No additional configuration is required for iOS.:

Usage #

Here’s a complete example showing how to use the fz_google_oauth2 package to get access to Google APIs and login.

usage google_oauth2 #


final result = await
FzGoogleOauth2Services.login
(
tenantId: "YOUR_TENANT_ID",
clientId: "YOUR_CLIENT_ID",
clientSecret: "YOUR_CLIENT_SECRET",
scope: "YOUR_SCOPE",
email: _emailController.text,
password: _passwordController.text,
);

if (result != null) {
debugPrint("result: $result");
SnackBar snackBar =
SnackBar(content: Text("Your Token is ${result['access_token']}"));
// SnackBar(content: Text("Your Token is ${result['refresh_token']}"));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}

Custom Interceptors For Refresh Token #

  /// Generate Refresh token when expired token
/// By custom indicator
/// If you want to generate refresh token when expired token
/// in your app, you can use this method
/// using Dio interceptors
void generateCustomTokenWhenExpiredTokenByCustomIndicator() async {
  InterceptorsWrapper customInterceptors =
  FzGoogleOauth2Services.getCustomInterceptorsForRefreshToken(
    tenantId: "YOUR_TENANT_ID",
    clientId: "YOUR_CLIENT_ID",
    clientSecret: "YOUR_CLIENT_SECRET",
    scope: "YOUR_SCOPE",
    email: _emailController.text,
    password: _passwordController.text,
    getToken: () async {},
    saveToken: (String token) async {},
  );
  //then you can use your custom interceptors in your dio
  Dio dio = Dio();
  dio.interceptors.add(customInterceptors);
  //then you can use your custom interceptors in your dio
}

Example_Full_Code #

You Can Find The Full Code Here

Dependencies Used #

This package uses (You do not have to import them): #

dio:
Before using this example directly in a Flutter app, don't forget to add the fz_google_oauth2 
 to your pubspec.yaml file.
You can try out this example by replacing the entire content of main.dart file of a newly created
Flutter project.

About the Developer #

Hello! πŸ‘‹ I'm Fady Zaher, a Mid Level Flutter Developer with extensive experience in building high-quality mobile applications.


If you like this package, feel free to ⭐️ the repo and share it!

πŸ“ License MIT License

Copyright (c) 2025 [Fady Zaher]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

7
likes
120
points
31
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for Google OAuth.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter

More

Packages that depend on fz_google_oauth2