简体   繁体   English

Flutter Firebase Email 无密码登录 - 链接错误

[英]Flutter Firebase Email Passwordless login - Link giving error

I have a flutter app in which I'm trying to use firebase Email passwordless sign in. The sending part is working, but when I open the link I get an error:我有一个 flutter 应用程序,我在其中尝试使用 firebase Email 无密码登录。发送部分正在工作,但是当我打开链接时出现错误:

电子邮件登录链接 canHandleCodeInApp 错误

The handleCodeInApp parameter in the actioncode settings is true however.但是,actioncode 设置中的 handleCodeInApp 参数为 true。

_firebaseAuth.sendSignInLinkToEmail(
  email: email.value,
  actionCodeSettings: firebase_auth.ActionCodeSettings(
    url: uri.toString(),
    iOSBundleId: "myPackageName",
    androidPackageName: "myPackageName",
    androidMinimumVersion: '0',
    androidInstallApp: false,
    handleCodeInApp: true,
    dynamicLinkDomain: "myPackageName",
  ),
);

The Uri gets created here: Uri 在此处创建:

DynamicLinkParameters parameters = DynamicLinkParameters(
  uriPrefix: 'https://myRegisteredDomain',
  link: Uri.parse('https://myRegisteredDomain'),
  androidParameters: AndroidParameters(
    packageName: 'myPackageName',
    minimumVersion: 0,
  ),
  iosParameters: IosParameters(
    bundleId: 'myPackageName',
    minimumVersion: '0',
  ),
);
return await parameters.buildUrl();

Intent filter is set up as follows: Intent 过滤器设置如下:

<intent-filter>
    <action android:name="android.intent.action.VIEW"/>
    <category android:name="android.intent.category.DEFAULT"/>
    <category android:name="android.intent.category.BROWSABLE"/>
    <data android:host="myRegisteredDomain" android:scheme="https"/>
    <data android:host="myRegisteredDomain" android:scheme="http"/>
</intent-filter>

In firebase I have set up the domain as needed and it has been whitelisted.在 firebase 中,我根据需要设置了域,并且已将其列入白名单。 At this point I have no idea why I'm even getting this error as handleCodeInApp is set to true.在这一点上,我不知道为什么我什至会收到这个错误,因为 handleCodeInApp 设置为 true。 I can only guess that my link is incorrect in some way, but I wouldn't know where I set it up wrong.我只能猜测我的链接在某些方面不正确,但我不知道我在哪里设置错误。 If anyone knows where I went wrong or you need additional information, please tell me.如果有人知道我哪里出错了或者您需要更多信息,请告诉我。

Solution解决方案

  1. The Uri generated using the DynamicLinkParameters does not work.使用 DynamicLinkParameters 生成的 Uri 不起作用。 Just use a string like: "https://PROJECT.page.link".只需使用如下字符串:“https://PROJECT.page.link”。 This solved the error I was getting.这解决了我遇到的错误。

  2. The isSignInWithEmailLink check from FirebaseAuth isn't working correctly with version ^0.20.0+1, which I was using. FirebaseAuth 的 isSignInWithEmailLink 检查不适用于我使用的版本 ^0.20.0+1。 Reference https://github.com/FirebaseExtended/flutterfire/issues/4711#issuecomment-762323661 on how to fix this.有关如何解决此问题的参考https://github.com/FirebaseExtended/flutterfire/issues/4711#issuecomment-762323661 After this fix I can now use Passwordless sign in as intended修复此问题后,我现在可以按预期使用无密码登录

You should follow Firebase Email Link Authentication example guide at FlutterFire您应该遵循 FlutterFire 上的 Firebase Email 链接身份验证示例指南

https://firebase.flutter.dev/docs/auth/usage/#email-link-authentication https://firebase.flutter.dev/docs/auth/usage/#email-link-authentication

It works like a charm.它就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 无密码登录电子邮件链接过期时间太短 - Firebase passwordless login email link expiration time is too short Flutter 和 Firebase,无密码电子邮件身份验证? - Flutter & Firebase, passwordless email auth? Firebase 自定义无密码登录 email 模板 - Firebase customize passwordless login email template Expo 应用程序中的 Firebase 无密码电子邮件身份验证错误 - Firebase Passwordless Email Authentication Error in Expo App firebase 无密码身份验证如何与 Flutter 应用程序的动态链接一起使用? - How does firebase passwordless authentication work with dynamic link for a flutter app? 无密码电子邮件身份验证Firebase,动态链接(FDL) - Passwordless Email Auth Firebase, Dynamic Links (FDL) Angular 2 Firebase无密码登录-注册其他人 - Angular 2 Firebase passwordless login - register another person Firebase 魔术 Email 链接连同密码登录 - Firebase Magic Email link together with Password Login 用于电子邮件链接身份验证的 flutter ERROR_INVALID_ACTION_CODE 中的 firebase 身份验证 - firebase authentication in flutter ERROR_INVALID_ACTION_CODE for email link authentication 使用为 Google 帐户提供“身份验证/错误密码”的电子邮件的 Firebase 登录 - Firebase login with email giving "auth/wrong-password" for a Google account
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM