简体   繁体   English

使用 python 从 firebase 注销

[英]signout from firebase using python

Iam using django webapp.I signed in with我正在使用 django webapp.I 登录

import pyrebase

firebase = pyrebase.initialize_app(config)
authe = firebase.auth()
user = authe.sign_in_with_email_and_password(email,password)

How can I signout in similar way.我怎样才能以类似的方式注销。

You can call the signOut() function provided by the firebase.auth interface and as the documentation states:您可以调用 firebase.auth 接口提供的 signOut () function,如文档所述:

Signs out the current user.注销当前用户。

So in your example:所以在你的例子中:

authe.signOut()

The best way to to logout is to use django session, with the help of below function you can destroy token id on logout:注销的最佳方法是使用 django session,借助以下 function,您可以在注销时销毁令牌 ID:

def logout(request):
    try:
        del request.session['token_id']
    except KeyError:
        pass
    return HttpResponse("You're logged out.")

For complete details, refer to the django session documentation at:有关完整的详细信息,请参阅 django session 文档,网址为:

https://docs.djangoproject.com/en/2.2/topics/http/sessions/ https://docs.djangoproject.com/en/2.2/topics/http/sessions/

This should work....这应该工作....

firebase = pyrebase.initialize_app(firebaseConfig)
auth = firebase.auth()

You should use firebase-admin, avoid work arounds like this.你应该使用 firebase-admin,避免这样的变通。

auth.current_user = None

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 注销前更新 firebase 数据 - update firebase data before signout 注销前删除 firebase 侦听器 - Removing firebase listener before signout 使用 Firebase.auth.signOut() 不会将用户完全注销 - Using Firebase.auth.signOut() doesn't sign the user out completely 使用 Firebase 身份验证在 NextJS 中注销不起作用 - signOut in NextJS with Firebase Authentication does not Work 如何自动注销 flutter 中的 firebase 用户? - How to auto signOut a firebase user in flutter? 我正在尝试使用 Firebase 在 Flutter 中使用 Google 注销,但它不起作用 - I'm trying to signOut with google in Flutter with Firebase and it doesn't work Firebase Auth Signout 未推送到 React 中的主页 web 应用程序 - Firebase Auth Signout not pushing to homepage in React web app Firebase 用户注销在本机反应中不起作用 - Firebase user signOut doesn't work in react native 使用 Python 从 firebase 身份验证中提取创建日期和上次登录 - Extract Created date and last login from firebase authentication using Python 如何使用 firebase_admin 从 python 中的 firebase 存储中下载文件 - How to download file from firebase storage in python using firebase_admin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM