abraham / birb

WIP: Instagram for birds built in Flutter
https://bendyworks.com/blog/a-month-of-flutter
MIT License
95 stars 19 forks source link

Handle sign in failure #48

Open abraham opened 5 years ago

abraham commented 5 years ago

In Auth#signInWithGoogle, handle googleSignIn.signIn returning null, or a user clicking cancel (and any other likely to happen failures). If a failure happens then the users should probably be shown an error snackbar.

Related #49.

Methods that are likely to fail:

Relevant file: https://github.com/abraham/birb/pull/44/files#diff-122192ef8946fb1a2ce64cd05629c825R16

thisroot commented 5 years ago

Hi, i was try to you app, and got the this error. I have one question. Must i had registered user into my firebase or this method make registering users?

abraham commented 5 years ago

@thisroot There shouldn't be anything needed to specifically register users in Firebase. Make sure you have followed the Firebase configuration setup steps though: Android / iOS. If sign in still doesn't work, please open a new issue.

geminiyellow commented 5 years ago

hi @abraham , signInWithGoogle is gone,

ref: https://github.com/flutter/flutter/issues/27133#issuecomment-457858951

we can use it like this:

  Future<String> _testSignInWithGoogle() async {
    final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
    final GoogleSignInAuthentication googleAuth =
        await googleUser.authentication;
    final AuthCredential credential = GoogleAuthProvider.getCredential(
      accessToken: googleAuth.accessToken,
      idToken: googleAuth.idToken,
    );
    final FirebaseUser user = await _auth.signInWithCredential(credential);
    assert(user.email != null);
    assert(user.displayName != null);
    assert(!user.isAnonymous);
    assert(await user.getIdToken() != null);

    final FirebaseUser currentUser = await _auth.currentUser();
    assert(user.uid == currentUser.uid);

    return 'signInWithGoogle succeeded: $user';
  }
abraham commented 5 years ago

@geminiyellow Thanks for the notice.