使用 Django 的 Firebase 令牌身份验证 [英] Firebase Token Authentication using Django

查看:24
本文介绍了使用 Django 的 Firebase 令牌身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 django 的新手,正在尝试使用 firebase admin sdk 对用户进行身份验证.我正在尝试进行令牌身份验证并在我的 django 应用程序中设置了管理 sdk.我也收到了 android 应用程序中的客户端 ID 令牌.

I am new to django and am trying to get the user authenticated using firebase admin sdk. I am trying to do token authentication and have setup the admin sdk in my django app. Also I have received the client id token in the android app.

现在我无法理解如何将此 ID 发送到后端并验证它作为用户并相应地创建用户.我确实找到了 this 答案,但无法真正理解如何解决这个问题.

Now I am unable to understand how to send this id to the backend and verify it as a user and create users accordingly.I did find this answer but couldn't really understand how to go about this.

此外,如果验证了用户,我该如何添加和更新其数据.我是再次传递令牌还是有其他方法可以做到这一点?

Also if a user is verified how do I add and update its data. Do I pass the token again or is there any other way to do it?

推荐答案

您的 Android 应用应将其 ID 令牌与发送到后端服务器的所有请求一起发送.您可以决定如何包含它(作为标头、作为 JSON 有效负载的一部分等).在后端服务器中,如果令牌无法验证,您应该始终调用 auth.verify_id_token() 并返回错误(例如 401 Unauthorized).

Your Android App should send its ID token along with all requests sent to the backend server. You can decide how to include that (as a header, as part of a JSON payload etc). In the backend server, you should always call auth.verify_id_token() and return an error (e.g. 401 Unauthorized) if the token fails to validate.

这篇关于使用 Django 的 Firebase 令牌身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆