Visit Python firebase authentication Definitive guide (2021) for more
Sign in anonymously
Sometimes you need to use user's features without creating an account. So you can do it on firebase just by sending another POST request to :
https://identitytoolkit.googleapis.com/v1/accounts:signUp
But You have to enable it first
Code :
import requests
apikey='...................'# the web api key
def SignInAnonymously():
headers = {
'Content-Type': 'application/json',
}
data='{"returnSecureToken":"true"}'
r = requests.post('https://identitytoolkit.googleapis.com/v1/accounts:signUp?key={}'.format(apikey), headers=headers, data=data)
if 'error' in r.json().keys():
return {'status':'error','message':r.json()['error']['message']}
if 'idToken' in r.json().keys():
return {'status':'success','idToken':r.json()['idToken']}
Output :
{'status': 'success',
'idToken': 'eyJhbGciOiJSUzI1NiIsImtpZCI6IjkwMDk1YmM2ZGM2ZDY3NzkxZDdkYTFlZWIxYTU1OWEzZDViMmM0'}
Read more Python firebase authentication Definitive guide (2021)
Top comments (0)