Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine if Google Sign-In is cancelled #101

Open
mr5z opened this issue Sep 11, 2019 · 2 comments
Open

Determine if Google Sign-In is cancelled #101

mr5z opened this issue Sep 11, 2019 · 2 comments

Comments

@mr5z
Copy link

mr5z commented Sep 11, 2019

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.}"

@trevoriancox
Copy link

I am catching System.Threading.Tasks.TaskCanceledException in this case. Works for me.

@mr5z
Copy link
Author

mr5z commented Nov 14, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants