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

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

问题描述

我是django的新手,正在尝试使用firebase admin sdk对用户进行身份验证.我正在尝试进行令牌身份验证,并在django应用中设置了admin 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发送到后端并以用户身份验证并相应地创建用户.我确实找到了

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天全站免登陆