S
S
s_stepashka2021-06-16 10:30:55
RESTful API
s_stepashka, 2021-06-16 10:30:55

How to log out using firebase REST API?

Good afternoon. I am doing a simple user authentication using the Firebase REST API following this guide:
https://firebase.google.com/docs/reference/rest/auth
Sign In:

await fetch(
            'https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=AIzaSyAgTJyexl3AhXyoRfnB6LSyv0ZBoaP3Nm8',
            {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({
                    email: values.username,
                    password: values.password,
                    returnSecureToken: true,
                }),
            },
        )
            .then((response) => response.json())
            .then((response) => console.log(response));

and sign up:
await fetch(
            'https://identitytoolkit.googleapis.com/v1/accounts:signUp?key=AIzaSyAgTJyexl3AhXyoRfnB6LSyv0ZBoaP3Nm8',
            {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({
                    email: values.username,
                    password: values.password,
                    returnSecureToken: true,
                }),
            },
        )
            .then((response) => response.json())
            .then((response) => console.log(response));

go with a bang, the user registers, appears in the system, but remains logged in forever ...
The manual does not contain a clause about LOG OUT. Googling didn't help unfortunately.
This is a simple form through email and password. Can anyone come across? To understand At least what endpoint the request should have and what to send there?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
n1ksON, 2021-06-16
@n1ksON

curl 'https://identitytoolkit.googleapis.com/v1/accounts:update?key=[API_KEY]' \
-H 'Content-Type: application/json' \
--data-binary '{"idToken":"[FIREBASE_ID_TOKEN]","deleteProvider":["[facebook.com]"]}'

Documentation
In general, I use firebase in React via npm and I advise you.
Then it would work like this: firebase.auth().signOut()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question