Starting with google_sign_in ^7.0.0, the plugin underwent a major refactor to support the Android Credential Manager and modern Google Identity Services. This introduced several breaking changes that move away from the traditional “all-in-one” signIn() method.
If you recently upgraded your Flutter project, you may suddenly encounter multiple compilation errors or unexpected behavior.
Common issues include:
-
GoogleSignIn()constructor no longer exists -
signIn()method is removed -
accessTokenmissing fromGoogleSignInAuthentication - Account picker not appearing unless
initialize()is called
These changes can be confusing at first, but they come from an architectural shift where authentication and authorization are now handled separately.
Let’s go through the changes and how to fix them.
Fix 1 — GoogleSignIn Constructor Removed (Singleton Pattern)
The GoogleSignIn class no longer allows you to create new instances using GoogleSignIn().
To ensure compatibility with the system-level Credential Manager sheet, the plugin now uses a singleton pattern.
Replace your constructor call with:
final googleSignIn = GoogleSignIn.instance;
Fix 2 — Initialization Is Now Mandatory
In previous versions, initialization happened implicitly.
Starting with v7.0.0, you must call and await the initialize() method exactly once before using the plugin.
Call this during app startup (for example in main() or your authentication service initialization):
await GoogleSignIn.instance.initialize();
If initialization is skipped, the authentication sheet may not appear.
Fix 3 — signIn() Replaced by authenticate()
The familiar signIn() method has been replaced by authenticate().
This method triggers the new system-level account picker / Credential Manager sheet on supported Android versions.
Example:
final GoogleSignInAccount googleUser = await GoogleSignIn.instance.authenticate();
Fix 4 — accessToken Missing (Authentication vs Authorization)
This is the biggest architectural change in google_sign_in 7. Google has separated authentication (who the user is) from authorization (what permissions the app has).
After calling authenticate(), you can still obtain the idToken from googleUser.authentication. However, the accessToken is no longer returned automatically. To retrieve it, you must explicitly request scopes using the authorizationClient.
final clientAuth =
await googleUser.authorizationClient.authorizeScopes(['email', 'profile']);
Complete google_sign_in 7.0.0+ Implementation
If you need both tokens (for example when integrating with Firebase or other APIs), the following pattern works:
Future<UserCredential> signInWithGoogle() async {
// 1. Ensure initialization
final googleSignIn = GoogleSignIn.instance;
// 2. Authentication (Identity)
// Triggers the account picker / Credential Manager sheet
final GoogleSignInAccount googleUser =
await googleSignIn.authenticate();
// 3. Authorization (Permissions)
// Request scopes to retrieve the Access Token
final List<String> scopes = ['email', 'profile'];
final clientAuth =
await googleUser.authorizationClient.authorizeScopes(scopes);
// 4. Create Firebase Credential
final credential = GoogleAuthProvider.credential(
idToken: googleUser.authentication.idToken,
accessToken: clientAuth.accessToken,
);
// 5. Sign in to Firebase
return await FirebaseAuth.instance.signInWithCredential(credential);
}
IMPORTANT: Make sure GoogleSignIn.instance.initialize() is called once during app startup before invoking signInWithGoogle().
Final Thoughts
If you're upgrading from older versions of google_sign_in, these changes can feel confusing at first because many familiar APIs were removed or redesigned.
However, once you understand the separation between authentication and authorization, the new API flow becomes much clearer and aligns better with modern identity systems.
Hopefully this saves someone else the debugging time.
Top comments (0)