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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃摎] Facebook Login Documentation - Authentication #4404

Closed
Rahul-Vijay opened this issue Dec 16, 2020 · 3 comments
Closed

[馃摎] Facebook Login Documentation - Authentication #4404

Rahul-Vijay opened this issue Dec 16, 2020 · 3 comments
Labels
good first issue Good for newcomers plugin: auth type: documentation Improvements or additions to documentation

Comments

@Rahul-Vijay
Copy link

The current documentation -
Authentication --> Social Auth under the Facebook section has the following code:

Future<UserCredential> signInWithFacebook() async {
  // Trigger the sign-in flow
  final LoginResult result = await FacebookAuth.instance.login();

  // Create a credential from the access token
  final FacebookAuthCredential facebookAuthCredential =
    FacebookAuthProvider.credential(result.accessToken.token);

  // Once signed in, return the UserCredential
  return await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);
}

The following lines should be replaced:

// replace this
final LoginResult result = await FacebookAuth.instance.login();

// with this
final AccessToken result = await FacebookAuth.instance.login();

And

// replace this
final FacebookAuthCredential facebookAuthCredential =
    FacebookAuthProvider.credential(result.accessToken.token);

// with this
final FacebookAuthCredential facebookAuthCredential =
    FacebookAuthProvider.credential(result.token);

For reference facebook_auth.dart -

Future<AccessToken> login({
    ...
  }

I couldn't understand why it didn't import LoginResult, after going through the code, turns out there is no defined LoginResult class and the async method FacebookAuth.instance.login() returns an AccessToken object. Hope this helps.
Thanks!

@Rahul-Vijay Rahul-Vijay added good first issue Good for newcomers type: documentation Improvements or additions to documentation labels Dec 16, 2020
@Krunal3909
Copy link

Can I work on this issue?

@rrousselGit
Copy link
Contributor

Closing as this was fixed

@anburocky3
Copy link

New codes are not working, old codes are working anyhow.

New Codes:

Future<UserCredential> signInWithFacebook() async {
  try {
        // Trigger the sign-in flow
        final AccessToken result = await FacebookAuth.instance.login();
    
        // Create a credential from the access token
        final FacebookAuthCredential facebookAuthCredential = FacebookAuthProvider.credential(result.token);
    
        // Once signed in, return the UserCredential
        return await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);

    } on FirebaseAuthException catch (e) {
       handleErrors(e);
}

This works:

Future<UserCredential> signInWithFacebook() async {
  try {
      final LoginResult result = await FacebookAuth.instance.login();

      // Create a credential from the access token
      final FacebookAuthCredential facebookAuthCredential = FacebookAuthProvider.credential(result.accessToken.token);

      // Once signed in, return the UserCredential
      return await FirebaseAuth.instance.signInWithCredential(facebookAuthCredential);

    } on FirebaseAuthException catch (e) {
       handleErrors(e);
}

@firebase firebase locked and limited conversation to collaborators Jun 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
good first issue Good for newcomers plugin: auth type: documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants