firebase auth_在节点js项目上使用firebase auth

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.

这是高处的草图。

Image for post
Image for post

首先,您需要一个基本步骤。 (First, you need a basic step.)

  1. Install the firebase and express with npm module

    安装Firebase并使用npm模块表达
  2. 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.

您可能需要一个类似我所使用的占位符图像。

Image for post

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值