'signout from firebase using python

Iam using django webapp.I signed in with

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.



Solution 1:[1]

You can call the signOut() function provided by the firebase.auth interface and as the documentation states:

Signs out the current user.

So in your example:

authe.signOut()

Solution 2:[2]

The best way to to logout is to use django session, with the help of below function you can destroy token id on logout:

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:

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

Solution 3:[3]

This should work....

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

You should use firebase-admin, avoid work arounds like this.

auth.current_user = None

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 IsakBosman
Solution 2 Pika Supports Ukraine
Solution 3 wiltonsr