-
-
Notifications
You must be signed in to change notification settings - Fork 262
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Code: Future signInWithGoogle() async {
try {
const webClientId = 'xxxxx';
const iosClientId = 'xxxxx';
final GoogleSignIn googleSignIn = GoogleSignIn(
clientId: iosClientId,
serverClientId: webClientId,
);
final googleUser = await googleSignIn.signIn();
final googleAuth = await googleUser!.authentication;
final accessToken = googleAuth.accessToken;
final idToken = googleAuth.idToken;
if (accessToken == null) {
throw 'No Access Token found.';
}
if (idToken == null) {
throw 'No ID Token found.';
}
final response = await client.auth.signInWithIdToken(
provider: OAuthProvider.google,
idToken: idToken,
accessToken: accessToken,
);
if (response.user != null) {
return await _handleSocialSignIn(user: response.user!, authMethod: 'google');
} else {
return AuthResult.error('Google sign-in failed. Please try again.');
}
} on AuthException catch (e) {
log('❌ AuthException during Google Sign-In: ${e.message}');
return AuthResult.error('Could not sign in with Google. ${e.message}');
} on Exception catch (e) {
log('❌ General Exception during Google Sign-In: $e');
return AuthResult.error(
'An unexpected error occurred. Please try again.',
);
}
}
Getting exceptions like:
-
The class 'GoogleSignIn' doesn't have an unnamed constructor.
Try using one of the named constructors defined in 'GoogleSignIn'. -
The method 'signIn' isn't defined for the type 'GoogleSignIn'.
Try correcting the name to the name of an existing method, or defining a method named 'signIn'.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working