[英]Sign in with google using firebase
I am working on a react app that lets a user sign in with user.我正在开发一个允许用户使用用户登录的反应应用程序。 I am using Firebase to handle authentication.
我正在使用 Firebase 来处理身份验证。 I am using express to write cloud functions.
我正在使用 express 编写云函数。 I want to set up signing in with Google but I have a couple of questions.
我想设置使用 Google 登录,但我有几个问题。
Here is what I have so far on the backend of the route to sign in with Google:到目前为止,我在使用 Google 登录的路线的后端拥有以下内容:
const { id_token } = req.body //de-structure id token passed in through body of request
const credential = firebase.auth.GoogleAuthProvider.credential(id_token);
How do I register this user using these credentials into my database?如何使用这些凭据将此用户注册到我的数据库中? How do I check if this user is already registered?
如何检查此用户是否已注册? I want to be able to save data for this user so every time he/she logs in with google, his/her data is saved.
我希望能够为该用户保存数据,因此每次他/她使用 google 登录时,都会保存他/她的数据。
You should import firebase admin in your application.您应该在您的应用程序中导入 firebase admin 。
Admin SDK allows to interact with firebase from the privileged environment to perform actions like:管理员 SDK 允许从特权环境与 firebase 交互以执行以下操作:
I hope this helps.我希望这有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.