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

Back button during Facebook/Twitter flow shows 'Provider Error' #1572

Closed
nole87 opened this issue Jan 20, 2019 · 23 comments
Closed

Back button during Facebook/Twitter flow shows 'Provider Error' #1572

nole87 opened this issue Jan 20, 2019 · 23 comments

Comments

@nole87
Copy link

nole87 commented Jan 20, 2019

Step 1: Are you in the right place?

I think I am :)

Step 2: Describe your environment

All android devices

implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.firebaseui:firebase-ui-auth:4.3.1'

Step 3: Describe the problem:

When user try to sing in via firebase auth UI, and when user click on facebook or twitter provider and if he press android back he get toast message "Provider error". If he continue to singin via facebook or twitter it works but if user press bach he get error message. All is configured.

Steps to reproduce:

download test project from this link and try it: https://drive.google.com/file/d/1viGBLvyoMf5Tyedffuo0ZY8sMBPn6UqK/view?usp=sharing

For facebook provider all is configured, for twitter in this test project it isn't and you don't get for twitter provider toast error, only for facebook ...

Observed Results:

User see wrong toast error message

Expected Results:

there should not be any toast message when user goes back to previous screen

@samtstern
Copy link
Contributor

@nole87 just to make sure I understand, is this the correct step sequence to reproduce?

  1. Start sign in with Facebook (or Twitter)
  2. At some point in the middle of the sign in flow, press back
  3. FirebaseUI displays a "Provider Error" toast when it should say "Canceled" or nothing

@samtstern samtstern added the auth label Jan 22, 2019
@samtstern samtstern changed the title Firebase Auth UI Back button during Facebook/Twitter flow shows 'Provider Error' Jan 22, 2019
@samtstern samtstern added this to the 4.3.2 milestone Jan 22, 2019
@nole87
Copy link
Author

nole87 commented Jan 22, 2019

when facebook or twitter is open and user can enter username and password than if user press back he get error message. Download from this link short clip: https://drive.google.com/file/d/1KGl0MnOW-M4HntMr9ZLi5n56bTkaGDLP/view?usp=sharing

@samtstern
Copy link
Contributor

Thanks @nole87 that's a clear reproduction of the bug!

@joseustra
Copy link

Hey.

There is someone working on this issue? If not, I'd like to give a try.

Thanks.

@samtstern
Copy link
Contributor

@ustrajunior I haven't had time to look at it yet, if you want to try please do! I'd be happy to review the PR

@maneletorres
Copy link

Good afternoon!

I am developing an application that starts with an activity for user authentication through email, Google, Facebook and Twitter, and I get the same error as @nole87 .

Additionally, when the application is running, I get the following errors:

Email / Google:
E/AuthUI: A sign-in error occurred.
com.firebase.ui.auth.data.model.UserCancellationException: Unknown error

NOTE: in the case of Google, the error appears three times.

Facebook:
E/AuthUI: A sign-in error occurred.
com.firebase.ui.auth.FirebaseUiException: Provider error
Caused by: null

NOTE: the error appears three times.

Twitter:
First error:
E/Twitter: Authorization completed with an error
com.twitter.sdk.android.core.TwitterAuthException: Authorization failed, request was canceled.

Second error:
E/AuthUI: A sign-in error occurred.
com.firebase.ui.auth.FirebaseUiException: Provider error
Caused by: com.twitter.sdk.android.core.TwitterAuthException: Authorization failed, request was canceled.

NOTE: the second error appears three times.

Does the same behavior occur to you @nole87, @ustrajunior ?

@mbladel
Copy link

mbladel commented Mar 19, 2019

Hello,
I'm getting this same problem when going back (with button) or canceling both Twitter and Facebook logins.
Any updates or known workarounds to avoid the error Toast?
Thanks.

@joseustra
Copy link

This week I will be working on this issue to try to find a solution. Hope to have something to the end of this week.

@samtstern
Copy link
Contributor

@ustrajunior nice! Thanks for the update.

@joseustra
Copy link

@samtstern I believe I found the problem.

For facebook callback, the onCancel method handles the cancel calling the onError method here: L112.

I changed the onCancel method to this:

public void onCancel() {
	setResult(Resource.<IdpResponse>forFailure(new FirebaseUiException(
		ErrorCodes.SIGNIN_CANCELED, new FacebookException())));
}

and I had to add SIGNIN_CANCELED to the ErrorCodes.java file.

With this change, instead of "Provider error" it will show "The sign in process was canceled".

The onError will continue to act the same way.

For Twitter, it's a little different because there is no onCancel, just onFailure. I'm not sure, yet, if there is an easy way to differentiate an error of a cancel.

For Google, not sure yet. I'm having problems to reproduce the error, for me, occurs an error but it is not shown on the UI.

What do you think about this solution? If you think it's ok, I will continue following this path.

@nole87
Copy link
Author

nole87 commented Mar 22, 2019

Only facebook and twitter providers show toast msg when user cancel auth process. In my opinion best if possible no toast msg at all but if not possible or too much time it takes to resolve than some appropriate msg is good enough ...

@samtstern
Copy link
Contributor

@ustrajunior that definitely seems like the right start to a solution!

@samtstern
Copy link
Contributor

Going to move this to the next release milestone (4.4.0) to give @ustrajunior more time to come up with a solution.

@samtstern samtstern modified the milestones: 4.3.2, 4.4.0 Mar 26, 2019
@joseustra
Copy link

Thanks, @samtstern. Last week was crazy for me so I was not able to work on the issue. Til the end of this week, I hope to have a more concrete solution.

@KryptKode
Copy link

@ustrajunior. Have you been able to come up with a solution now?

@KryptKode
Copy link

KryptKode commented May 7, 2019

I think I have come up with a solution. I attached a snippet for the Facebook callback in the FacebookSignInHandler class . In the onCancel method, you can return a UserCancellationException instead.

 @Override
        public void onCancel() {
            setResult(Resource.<IdpResponse>forFailure(new UserCancellationException()));
        }

studio64_2019-05-07_07-56-35

For Google sign-in you can check the status code in onActivityResult of the GoogleSignInHandler class:

if (e.getStatusCode() == GoogleSignInStatusCodes.SIGN_IN_CANCELLED) {
                    Timber.e(e);
                    setResult(Resource.<IdpResponse>forFailure(new UserCancellationException()));
                }

studio64_2019-05-07_08-01-18

The same idea can be applied to the other providers...

@joseustra
Copy link

Hey @KryptKode. Unfortunately, I did not have the time to work on this issue. You can get it if you want.

@felipe-gouveia
Copy link
Contributor

Hi @samtstern I'm carrying on @ustrajunior 's work here since he just became a parent, yupi! :) We are currently doing a project at Universidade do Porto and this issue is part of an assignment of contributing to opensource. I believe @ustrajunior already solves the issue in the reply below, since #1627 removes TwitterSignInHandler and it doesn't make sense to temper with it for now.

Also, just a tweek into his comment, since the toast message is an alert to the user, it makes more sense to display the message "The sign in process was canceled" to the user and to the developer show "The sign in process was canceled by the user".

@KryptKode regarding the Google SignIn there is currently not issue with the back button, so don't think it's necessary. But your solution to the Facebook is nice and almost the same as @ustrajunior, but I think that since we already have a FirebaseUiException which is overloaded to support the exceptions message we should use it.

I have submitted a pull request with the solution in #1630

@samtstern I believe I found the problem.

For facebook callback, the onCancel method handles the cancel calling the onError method here: L112.

I changed the onCancel method to this:

public void onCancel() {
	setResult(Resource.<IdpResponse>forFailure(new FirebaseUiException(
		ErrorCodes.SIGNIN_CANCELED, new FacebookException())));
}

and I had to add SIGNIN_CANCELED to the ErrorCodes.java file.

With this change, instead of "Provider error" it will show "The sign in process was canceled".

The onError will continue to act the same way.

For Twitter, it's a little different because there is no onCancel, just onFailure. I'm not sure, yet, if there is an easy way to differentiate an error of a cancel.

For Google, not sure yet. I'm having problems to reproduce the error, for me, occurs an error but it is not shown on the UI.

What do you think about this solution? If you think it's ok, I will continue following this path.

@samtstern
Copy link
Contributor

@felipe-gouveia thanks for the PR and @ustrajunior congrats on becoming a parent! This week I am super busy with Google I/O so I will get to this as soon as I can.

@joseustra
Copy link

Thanks, @samtstern. Time is something rare, for me, right now ;D

@samtstern
Copy link
Contributor

Facebook will be fixed in 5.0.0 thanks to @ustrajunior and @felipe-gouveia, and we can work on Twitter for 5.0.1

@samtstern samtstern modified the milestones: 5.0.0, 5.0.1 May 21, 2019
@tayaza
Copy link

tayaza commented Aug 2, 2019

Facebook will be fixed in 5.0.0 thanks to @ustrajunior and @felipe-gouveia, and we can work on Twitter for 5.0.1

Hi @samtstern, @ustrajunior, and @felipe-gouveia, I still get the error in 5.0.0. Is there something I am doing wrong or is it yet to be fixed? Thanks for the good work.

@samtstern
Copy link
Contributor

The fix for this issue has been released in version 6.2.1

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

No branches or pull requests

8 participants