首页 > 解决方案 > 我如何使用云功能注册 Firebase?

问题描述

我正在学习使用云功能,并且可以使用该方法创建用户admin.auth().createUser,但现在我想用谷歌帐户注册

我尝试使用admin.auth().GoogleAuthProvider()但告诉我GoogleAuthProvider() 不存在

标签: firebasegoogle-cloud-functionsfirebase-admin

解决方案


并不总是可以使用 admin sdk。例如,我正在使用 Google Actions,并且已经解决了 firebase 依赖项(npm i --save firebase)。 https://firebase.google.com/docs/auth/web/google-signin?hl=es-419

async function createUser(token: string) {
    // Build Firebase credential with the Google ID token.
    const credential = firebase.auth.GoogleAuthProvider.credential(token);
    const userCredential = await firebase.auth().signInWithCredential(credential);
}


推荐阅读