I want to authenticate user using google signin in my app and if the authenticaton is successful, I will send the access token to the server and the server will then create an account to that user using the access token to get the user information. whenever the user clicks on the button to do that, it will bring the google account associated to the device for the user to select and when I select it, it throws thhis erro. GoogleSignInException(code GoogleSignInExceptionCode.canceled, activity is cancelled by the user., null). This is the version of google signin I am using. google_sign_in: ^7.2.0
void googleLogin() async {
final googleSignIn = GoogleSignIn.instance;
try {
if (googleSignIn.supportsAuthenticate()) {
await googleSignIn
.initialize(serverClientId: AppConstants.googleOAuthClientId)
.then((_) async {
googleSignIn.signOut();
GoogleSignInAccount googleAccount = await googleSignIn
.authenticate();
const List scopes = ['email'];
GoogleSignInClientAuthorization? auth = await googleAccount
.authorizationClient
.authorizationForScopes(scopes);
if (auth != null) {
authBloc.add(
GoogleRegistrationEvent(googleToken: auth.accessToken),
);
}
});
} else {
showToast('Google Sign-In not supported on this device');
debugPrint("Google Sign-In not supported on this device.");
}
} catch (e) {
pp(e.toString());
debugPrint('Error in google sign in: $e');
}
}