0

I'm trying to use the flutter_facebook_auth 3.3.2+2 package and the firebase_auth 1.0.3 to do the facebook login, I basically copy and paste the code from their doc https://facebook.meedu.app/#/firebase-auth

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter_facebook_auth/flutter_facebook_auth.dart';

Future<UserCredential?> signInWithFacebook() async {
  final LoginResult result = await FacebookAuth.instance.login();
  if(result.status == LoginStatus.success){
    // Create a credential from the access token
    final OAuthCredential credential = FacebookAuthProvider.credential(result.accessToken!.token);
    // Once signed in, return the UserCredential
    return await FirebaseAuth.instance.signInWithCredential(credential);
  }
  return null;
}

I tried to login with it, but when it goes down to the code await FirebaseAuth.instance.signInWithCredential(credential); It pops the error: E/flutter (23237): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: [firebase_auth/invalid-credential] The supplied auth credential is malformed or has expired. [ Remote site 5XX from facebook.com for VERIFY_CREDENTIAL ]

I've checked all the app id, app secret, callback url, package name are matching, I have no clues what did I do wrong. Please can anybody tell me what is happening?

qwea
  • 476
  • 1
  • 5
  • 16

1 Answers1

2

There could be multiple reasons: Choosing wrong app type in Facebook console instead of "Build Connected Experiences"

enter image description here

Also:

  • Wrong bundle/app/package id/name
  • Bad API key and secrets
Adelina
  • 10,915
  • 1
  • 38
  • 46