我正在处理一段代码,尝试使用Firebase将Facebook身份验证凭据链接到当前用户。当前用户使用电子邮件/密码创建一个帐户,然后在以后的某个时间点将Facebook凭据链接到该帐户。该代码以前按预期工作,但是我们的团队需要更新多个Firestore依赖关系,这似乎已破坏了此代码。我不确定是什么问题。
我尝试检查令牌的内容,似乎没有任何问题。该代码始终在linkwithcredential函数中失败。否则,使用Facebook UI进行登录非常有效。 linkwithcredential函数始终会吐出相同的错误。
我的代码:
fbLogin.logInWithReadPermissions(['email', 'public_profile'])
.then((result) async
{
print(" == Right Before result.status");
switch(result.status)
{
case FacebookLoginStatus.loggedIn:
{
FacebookAccessToken myToken = result.accessToken;
print("AccessToken = ${myToken.token.toString()}");
AuthCredential credential = FacebookAuthProvider.getCredential(accessToken: myToken.token);
FirebaseUser us = await FirebaseAuth.instance.linkWithCredential(credential);
}
//... other cases & error handling
}
输出:
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): Failed to handle method call
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): java.lang.IllegalArgumentException: Given String is empty or null
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at com.google.android.gms.common.internal.Preconditions.checkNotEmpty(Unknown Source:5)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at com.google.firebase.auth.EmailAuthProvider.getCredential(Unknown Source:2)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin.handleLinkWithEmailAndPassword(FirebaseAuthPlugin.java:272)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at io.flutter.plugins.firebaseauth.FirebaseAuthPlugin.onMethodCall(FirebaseAuthPlugin.java:122)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:201)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:88)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:219)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at android.os.MessageQueue.next(MessageQueue.java:326)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at android.os.Looper.loop(Looper.java:181)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at android.app.ActivityThread.main(ActivityThread.java:6981)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
E/MethodChannel#plugins.flutter.io/firebase_auth(26676): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
I/flutter (26676): PlatformException(error, Given String is empty or null, null)
pubspec.yaml:
version: 1.0.0+1
environment:
sdk: ">=2.1.0 <3.0.0"
dependencies:
flutter_facebook_login:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
cloud_firestore: 0.10.1
firebase_database: ^1.0.5
firebase_auth: 0.8.1 #^0.6.6
google_sign_in: ^3.2.4
firebase_storage: ^1.0.4
webview_flutter: ^0.3.0
shared_preferences: ^0.4.3
cached_network_image: ^0.8.0
fluttertoast: ^3.0.4
flutter_auth_buttons: ^0.3.1
image_picker: ^0.6.0
image_cropper: ^1.0.1
auto_size_text: ^1.1.2
flutter_range_slider: "^1.1.0"
transparent_image: ^1.0.0
flutter_image: ^1.0.0
page_view_indicators: ^1.1.0
path: any
intl: ^0.15.8
stripe_payment: 0.1.0
geoflutterfire: ^2.0.3
latlong: ^0.6.1
firebase_messaging: 4.0.0+4
flutter_launcher_icons: 0.7.2
stripe: 1.3.1
强制性扑动医生:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.5.4-hotfix.2, on Microsoft Windows [Version 10.0.17134.829], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.3)
[√] Connected device (1 available)
• No issues found!
答案 0 :(得分:0)
在进行了广泛的在线搜索之后,似乎这是Firebase-Auth的问题。将Firebase-Auth从0.8.1更新到0.8.2解决了该问题。