buttonsrtoys
buttonsrtoys

Reputation: 2771

flutter_firebase_auth and "[firebase_auth/invalid-credential] Bad access token"

Facebook and Firebase auth are working for Android with my Flutter app but I'm having trouble with iOS. On iOS, I can login to Facebook fine, but when I then use the FB credentials to auth with Firebase, my call to signInWithCredential below

final credential = FacebookAuthProvider.credential(accessToken.tokenString);
await FirebaseAuth.instance.signInWithCredential(credential);

throws the error with error code invalid-credential:

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled 
Exception: [firebase_auth/invalid-credential] Bad access token

I followed the config instructions on Facebook, and I can auth with Facebook on Android, so I think Firebase config is OK. Any suggestions on what I'm missing?

EDIT:

Here's my redacted Info.plist file with my actual values replaced with {...} and unlrelated settings replaced with <!-- ... -->

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
  "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <!-- ... -->

    <key>LSApplicationQueriesSchemes</key>
    <array>
      <!-- Support url_launcher per docs -->
      <string>sms</string>
      <string>tel</string>

      <!-- Facebook login scheme -->
      <string>fbauth2</string>
    </array>

    <!-- ... -->

    <!-- Facebook App ID -->
    <key>FacebookAppID</key>
    <string>{MY APP ID}</string>

    <!-- Facebook Display Name -->
    <key>FacebookDisplayName</key>
    <string>{MY APP NAME}</string>

    <!-- Facebook Client Token -->
    <key>FacebookClientToken</key>
    <string>{MY CLIENT TOKEN}</string>

    <!-- Facebook URL Scheme -->
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>fb{MY APP ID}</string>
          <!-- Google Sign-In URL Scheme -->
          <!-- ... -->
        </array>
      </dict>
    </array>

  </dict>
</plist>

Upvotes: 2

Views: 692

Answers (1)

Ajit Sharma
Ajit Sharma

Reputation: 195

  1. Make sure you added debug key hash
  2. Verify Facebook App ID and Facebook Bundle ID

Upvotes: 1

Related Questions