SimpleAuth
SimpleAuth copied to clipboard
Determine if Google Sign-In is cancelled
Hi, can we have a way of knowing if the Google auth is cancelled? Right now, it just throws a generic Exception with a message:
"Error Domain=com.google.GIDSignIn Code=-5 "The user canceled the sign-in flow." UserInfo={NSLocalizedDescription=The user canceled the sign-in flow.}"
I am catching System.Threading.Tasks.TaskCanceledException in this case. Works for me.
@trevoriancox this is how I authenticate with Google:
try {
OAuthApi api = ... api.ResetData(); var account = await api.Authenticate(); if (!account.IsValid()) { return new DataResponse<AuthResponse> { ErrorType = HttpErrorType.Authentication }; } var authAccount = account as OAuthAccount;
} catch (Exception ex) {
if (ex is TaskCanceledException) { return new DataResponse<AuthResponse> { ErrorType = HttpErrorType.Cancelled }; } // TODO hack. wait for the issue to be fixed // https://github.com/Clancey/SimpleAuth/issues/101 if (ex.Message.Contains("com.google.GIDSignIn Code=-5")) { ... } ...
}
It does not go into if (ex is TaskCanceledException)
part when I cancel the sign-in flow since I'm always receiving a generic type Exception
where I need to make a hack.