firebase auth
I will describe the basic way of implementing Firebase Auth in Node.js project.
我将描述在Node.js项目中实现Firebase Auth的基本方法。
Here is a sketch on high.
这是高处的草图。
首先,您需要一个基本步骤。 (First, you need a basic step.)
- Install the firebase and express with npm module 安装Firebase并使用npm模块表达
- Make a new Firebase project on Firebase console. 在Firebase控制台上创建一个新的Firebase项目。
首先,Server.js (First, Server.js)
I’ve made one config.js and used it on both of Front and Server side.
我制作了一个config.js,并在前端和服务器端都使用了它。
You have to use your own configuration that you can retrieve from your firebase project console.
您必须使用自己的配置,可以从Firebase项目控制台中检索该配置。
二,index.html (Second, index.html)
You might need a placeholder image what like I used.
您可能需要一个类似我所使用的占位符图像。
Just take this.
就拿这个。
三,index.js (Third, index.js)
I’ve used signInWithPopup rather than use the way with redirecting. Most of the Lines is just for UI handling.
我使用了signInWithPopup而不是使用重定向的方式。 大多数行仅用于UI处理。
You just have to focus on the method, onAuthStateChanged
您只需要关注onAuthStateChanged方法
It would be fired when Auth status is changed by the user logs in with Google.
当用户使用Google登录更改身份验证状态时,将触发该事件。
翻译自: https://medium.com/weekly-webtips/to-use-firebase-auth-on-node-js-project-26ad96c0ff6a
firebase auth