我正在尝试实现 firebase 的 email link auth在 网络应用 上,我无法理解这里的问题所在。
我已按照他们在页面上的说明发送了电子邮件,并且正在发送,但问题是发送的 URL 无效。
async sendAuthEmail(email) {
var actionCodeSettings = {
// URL you want to redirect back to. The domain (www.example.com) for this
// URL must be whitelisted in the Firebase Console.
url: "http://localhost:3000",
// This must be true.
handleCodeInApp: true,
iOS: {
bundleId: "com.example.ios"
},
android: {
packageName: "com.example.android",
installApp: true,
minimumVersion: "12"
}
};
return await firebase
.auth()
.sendSignInLinkToEmail(email, actionCodeSettings);
}
发送的 URL 是(我更改了我的 firebaseapp 名称):
https://?link=https://myfirebasedbname.firebaseapp.com/__/auth/action?apiKey%3DAIzaSyDSio7vAbW7O0TVGCF2UpG7FsQDvHX0M7Q%26mode%3DsignIn%26oobCode%3DXoAsz5CoIJOhdhAcJpC2E3iWI8fmyTwJPIUmMlgLvakAAAFiy0Wm9A%26continueUrl%3Dhttp://localhost:3000&apn=com.example.android&amv=12&ibi=com.example.ios&ifl=https://myfirebasedbname.firebaseapp.com/__/auth/action?apiKey%3DAIzaSyDSio7vAbW7O0TVGCF2UpG7FsQDvHX0M7Q%26mode%3DsignIn%26oobCode%3DXoAsz5CoIJOhdhAcJpC2E3iWI8fmyTwJPIUmMlgLvakAAAFiy0Wm9A%26continueUrl%3Dhttp://localhost:3000
我也试过更改 url
参数,但还是失败了。
有什么想法可以分享吗?
谢谢!
最佳答案
您是否配置了 Firebase 动态链接域?您需要在 Firebase 控制台的动态链接部分执行此操作。
如果您仅将此用于仅用于网络的应用程序,则无需在 ActionCodeSettings
中包含 android
或 ios
字段> 对象。这避免了设置 FDL 的需要:
var actionCodeSettings = {
url: "http://localhost:3000",
// This must be true.
handleCodeInApp: true
};
关于javascript - sendSignInLinkToEmail 发送无效的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49847189/