Sign in
Log inSign up

Firebase Send email verification using python

Budy mnvenom's photo
Budy mnvenom
·Oct 11, 2021·

1 min read

CHECK PREVIOUS TUTORIAL AND EXPLANATION Python and firebase auth Now to send an email verification using python. You need to send a POST request to

https:identitytoolkit.googleapis.com/v1/accounts…

You need also the token that you get after sign in or sign up .

import requests

apikey='..................'# the web api key

idToken='eyJh1pVjuYvfX72ewSqUxRNUNoGKgdhsaYdeOjs9OsQ......'#token

def VerifyEmail(idToken):
    headers = {
        'Content-Type': 'application/json',
    }
    data='{"requestType":"VERIFY_EMAIL","idToken":"'+idToken+'"}'
    r = requests.post('identitytoolkit.googleapis.com/v1/accounts….format(apikey), headers=headers, data=data)
    if 'error' in r.json().keys():
        return {'status':'error','message':r.json()['error']['message']}
    if 'email' in r.json().keys():
        return {'status':'success','email':r.json()['email']}

run :

VerifyEmail(idToken)

result:

Success

{'status': 'success', 'email': ''}

The user will receive an email from you like this :

imageedit_4_5081572962.jpg Failed

{'status': 'error', 'message': 'INVALID_ID_TOKEN'}