简体   繁体   English

如何使用Firebase管理员API创建passwordResetLink?

[英]How to create a passwordResetLink using the Firebase admin API?

I'm trying customize the user experience in my firebase project and hence as well need to create custom email templates including the necessary action links. 我正在尝试自定义Firebase项目中的用户体验,因此也需要创建自定义电子邮件模板,其中包括必要的操作链接。

Unfortunately I'm unable to get my firebase cloud function to create the passwordResetLink . 不幸的是,我无法获得Firebase云功能来创建passwordResetLink No matter what I try the function doesn't seem to be valid despite being setup according to the firebase docs . 无论我尝试什么,尽管根据firebase docs进行了设置,但该功能似乎都无效。

Error: auth.generatePasswordResetLink is not a function 错误:auth.generatePasswordResetLink不是函数

I tried to reinstall the node_modules as well already but without any success :( 我已经尝试过重新安装node_modules,但是没有成功:(

const admin = require('firebase-admin');
const auth = admin.auth();
const functions = require('firebase-functions');

exports = module.exports = functions.https.onCall((data) => {

    const email = data.email
    const actionCodeSettings = {
        url: 'http://localhost:3000',
        handleCodeInApp: false
    };

    auth.generatePasswordResetLink(email, actionCodeSettings)
        .then((link) => {
        // return link
        return { link: link }
    })
        .catch((error) => {
        // Some error occurred.
    });

})

The function above should simply return the passwordResetLink so I can work with it afterwards to create a custom email template. 上面的函数应该只返回passwordResetLink以便以后可以使用它来创建自定义电子邮件模板。

You seem to be using an old version of firebase-admin . 您似乎正在使用旧版本的firebase-admin The API you're trying to invoke was added in v6.2.0 of the SDK. 您尝试调用的API已添加到SDK的v6.2.0中。 Make sure you have at least that version. 确保您至少具有该版本。

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

相关问题 使用Firebase Admin SDK进行REST API身份验证 - REST api authentication using firebase admin sdk Firebase管理员如何使用无密码登录创建用户? - Firebase admin how to create user with passwordless signin? 我可以使用admin authentication api手动在firebase中创建联合用户吗? - Can I create a federated user in firebase manually using admin authentication api? 如何使用 Firebase 创建 nodeJS API - How to create nodeJS API with Firebase 如何使用 firebase admin 向设备发送通知 - How to send a notification to device using firebase admin 使用Admin Firebase通过电话服务提供商创建带有电子邮件的用户 - Create users with email an phone provider using Admin Firebase 如何使用Firebase管理员SDK删除Firebase存储中的文件 - How to delete a file in Firebase Storage using firebase admin sdk 如何使用 firebase-admin 和 nodeJS 在 firebase 存储上上传图像 - How to upload images on firebase storage using firebase-admin and nodeJS 如何创建可以在 firebase 中添加用户的管理员? - How can I create an admin that can add users in firebase? 如何使用 firebase 管理员 SDK 创建具有社交提供者的租户? - How can I create a tenant with social provider with firebase admin SDK?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM