Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Fixes error handling in firebase_auth on Android and iOS #775

Merged
merged 1 commit into from
Nov 22, 2018

Conversation

slightfoot
Copy link
Member

@slightfoot slightfoot commented Sep 9, 2018

This standardises the error responses from the platform implementations. All functions in FirebaseAuth and FirebaseUser are now documented with error codes.

Fixes: flutter/flutter#18312 and Fixes: flutter/flutter#20223

This PR is based on #678 so includes the changes there.

Example:

PlatformException(ERROR_USER_NOT_FOUND, There is no user record corresponding to this identifier. The user may have been deleted., null)
PlatformException(ERROR_WRONG_PASSWORD, The password is invalid or the user does not have a password., null)
PlatformException(ERROR_NETWORK_REQUEST_FAILED, Network error (such as timeout, interrupted connection or unreachable host) has occurred., null)

Other changes include:

  • Added missing linkWithTwitterCredential method.
  • Updated deprecated API fetchProvidersForEmail to fetchSignInMethodsForEmail.
  • Added unlinkCredential.
  • Updated Changelog.

Full error code list can be found here:
https://docs.google.com/spreadsheets/d/1FDn0rRRYjgXMwc_FIAxO7_cQh69q5VXgQt7Hmvyb1Sg/edit?usp=sharing

Closes: #768 and Closes: #697 - Merged into this one.
Closes: #703 and #814

@slightfoot slightfoot changed the title Fix error handling in firebase_auth on Android and iOS Fixes error handling in firebase_auth on Android and iOS Sep 9, 2018
@slightfoot
Copy link
Member Author

@kroikie this is now ready for review and merge.

@slightfoot
Copy link
Member Author

Another big change in this code is that now all the dart code of firebase_auth is now documented.

@kroikie I just noticed my PR overlaps several others noted here. I just fixed things as I saw they were missing when adding the error logging.

Would be nice to see #718 merged in the same version release as this.

@kroikie kroikie self-assigned this Sep 10, 2018
@slightfoot slightfoot force-pushed the improved_error_handling branch from d26dd78 to f227aca Compare September 11, 2018 13:36
@filleduchaos
Copy link
Contributor

@slightfoot I don't mind you taking the changes from #768! :)

@escamoteur
Copy link

@eseidelGoogle could you check on this please? It's really a needed fix.

@eseidelGoogle
Copy link

@bparrishMines may also be able to help with reviews.

@bparrishMines bparrishMines self-requested a review September 26, 2018 22:37
@bparrishMines
Copy link
Contributor

HI @slightfoot,

Thanks for your contribution! Could you resolve the recent conflicts? I'll finish reviewing it as soon as you do.

@slightfoot slightfoot force-pushed the improved_error_handling branch from f227aca to 4d3ecab Compare September 27, 2018 23:46
@slightfoot
Copy link
Member Author

@bparrishMines think the analyze queue broken. Its been waiting a few hours. I'll double check all the formatting is good tomorrow when the results come in. Other than that, this is ready to go.

@slightfoot
Copy link
Member Author

@kroikie looks like the build server is borked. perhaps you can kick it. 😉

Copy link
Contributor

@bparrishMines bparrishMines left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of it looks great! I only have a few small comments. I'll see what I can do about the analyzer.

} else if (exception instanceof FirebaseApiNotAvailableException) {
result.error(
"ERROR_API_NOT_AVAILABLE",
"The API that you are calling is not available on devices without Google Play Services.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you not use exception.getMessage() for this and the other exceptions below?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

/// Completes with an error if the user is signed out.
///
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An extra space after documentation is unnecessary if we go by effective dart style guide. Same for comments below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, changed these also.

* `PlatformExceptions` now report error codes as stated in docs.
* Added support for `linkWithTwitterCredential` in `FirebaseAuth`.
* Added support for GitHub to `FirebaseAuth`.
* **Breaking Change** Renamed `fetchProvidersForEmail` to its new name `fetchSignInMethodsForEmail`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there is only deprecation, you don't have to put **Breaking Change**

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

@bparrishMines
Copy link
Contributor

cc @fkorotkov @gspencergoog Do you know why the analyze check is stuck here?

@HerrNiklasRaab
Copy link

When will this change be released?

@beardo01
Copy link

I support getting this merged too. Let's get it done please.

@kroikie
Copy link
Contributor

kroikie commented Nov 8, 2018

@slightfoot Sorry about the delay on this PR. Would you be able to rebase this on master then I'd be happy to merge.

@manhnhhdvn
Copy link

@bparrishMines , @kroikie

This PR is wonderful, but if it seems time consuming, could you review #703 and #814 first?

#703 is the unlink part of this PR.
#814 is the fetchSignInMethodsForEmail part of this PR.

@slightfoot slightfoot changed the title Fixes error handling in firebase_auth on Android and iOS WIP Fixes error handling in firebase_auth on Android and iOS Nov 19, 2018
@slightfoot slightfoot force-pushed the improved_error_handling branch 2 times, most recently from 765178e to 562f424 Compare November 19, 2018 22:32
@slightfoot slightfoot changed the title WIP Fixes error handling in firebase_auth on Android and iOS Fixes error handling in firebase_auth on Android and iOS Nov 19, 2018
@slightfoot
Copy link
Member Author

@bparrishMines @kroikie It's ready to merge.

@kroikie
Copy link
Contributor

kroikie commented Nov 20, 2018

@slightfoot sorry for the churn here, could you rebase then should be good to merge.

@slightfoot slightfoot force-pushed the improved_error_handling branch from 562f424 to 49366cf Compare November 20, 2018 17:48
@slightfoot
Copy link
Member Author

Rebased.

@slightfoot slightfoot force-pushed the improved_error_handling branch 2 times, most recently from b6801bb to 68bfa42 Compare November 21, 2018 23:32
Updated FireAuth docs.
Updated deprecated API "fetchProvidersForEmail" to "fetchSignInMethodsForEmail".
Added "unlinkCredential".
Updated changelog and brought wrapper inline with (flutter#915).
@slightfoot slightfoot force-pushed the improved_error_handling branch from 68bfa42 to 8da93c4 Compare November 21, 2018 23:36
@slightfoot slightfoot merged commit e96fb0c into flutter:master Nov 22, 2018
@slightfoot
Copy link
Member Author

@kroikie I've rebased again, and merged whilst I can, but leave the release to you.

@xqwzts
Copy link
Contributor

xqwzts commented Nov 23, 2018

@slightfoot Thanks for the long-awaited and hugely useful commit.

An official release would be appreciated as this fixes some critical bugs wrt error handling.

Renaming fetchProvidersForEmail to fetchSignInMethodsForEmail is a breaking change though, surely it warrants a mention in the changelog and a version bump?

@slightfoot
Copy link
Member Author

@xqwzts I was asked to remove my "breaking change" mention from the CHANGELOG and the @deprecated function I had because we have not yet reached stable API version, or something.

@HerrNiklasRaab
Copy link

How is the status? When will this be in beta?

@ghost
Copy link

ghost commented Nov 30, 2018

@slightfoot Do you know when this will be available?

@georgeherby
Copy link

If you want these changes before an official release but without the stuff in the proposed 0.7.0 in the change log
just add this to your yaml

  firebase_auth:
    git:
      url: git://github.com/flutter/plugins.git
      ref: e96fb0c350328ff77baae758b6dc70797117ac98
      path: packages/firebase_auth

The commit is of the stuff in this PR which in the changelog is 0.6.7 - just get the most recent commit if you want the stuff in 0.7.0 but that is nothing to do with this PR

@slightfoot
Copy link
Member Author

@kroikie is it possible to push this out. A lot of people are still waiting for this. 0.6.7 never got released. we are still on 0.6.6.

@baeharam
Copy link

Complete?

andreidiaconu pushed a commit to andreidiaconu/plugins that referenced this pull request Feb 17, 2019
Updated FireAuth docs.
Updated deprecated API "fetchProvidersForEmail" to "fetchSignInMethodsForEmail".
Added "unlinkCredential".
Updated changelog and brought wrapper inline with (flutter#915).
andreidiaconu added a commit to andreidiaconu/plugins that referenced this pull request Feb 17, 2019
julianscheel pushed a commit to jusst-engineering/plugins that referenced this pull request Mar 11, 2020
Updated FireAuth docs.
Updated deprecated API "fetchProvidersForEmail" to "fetchSignInMethodsForEmail".
Added "unlinkCredential".
Updated changelog and brought wrapper inline with (flutter#915).
@sumitrvi
Copy link

Hey i'm also facing google signin issue in ios
Unhandled Exception: PlatformException(ERROR_INTERNAL_ERROR, An internal error has occurred, print and inspect the error details for more information., null)
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
#1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)

#2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:349:48)
#3 MethodChannelFirebaseAuth.signInWithCredential (package:firebase_auth_platform_interface/src/method_channel_firebase_auth.dart:161:23)
#4 FirebaseAuth.signInWithCredential (package:firebase_auth/src/firebase_auth.dart:208:10)
#5 _AsyncAwaitCompleter.start (dart:async-patch/async_patch.dart:45:6)
#6 FirebaseAuth.signInWithCredential (package:firebase_auth/src/firebase_auth.dart:205:42)
#7 _SigninScreenState.socialLogin (package:down_beatflutterproject/screens/signinscreen.<…>

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

Successfully merging this pull request may close these issues.

How to handle firebase auth errors? FirebaseAuthPlugin: Error codes are not forwarded to Dart