python - Firebase email confirmation is not working - Stack Overflow

Firebase email confirmation is not workingI have set up email sending in Firebase Auth.The email arri

Firebase email confirmation is not working

I have set up email sending in Firebase Auth. The email arrives, but after clicking the generated link, the email_verified flag remains false.

Here is my code for sending the email.

    email_verify_response = requests.post(
        f':sendOobCode?key={FIREBASE_API_KEY}',
        json={"requestType": "VERIFY_EMAIL", "idToken": id_token}
    )
    email_verify_data = email_verify_response.json()

    if 'error' in email_verify_data:
        print("Ошибка при отправке email для подтверждения")
        return firebase_error_response(email_verify_data['error']['message'], 503)
    
    print("Email для подтверждения отправлен")

Here is the code for fetching the users (I run it after clicking the link to check the flag).

    users = []
    
    
    page = auth.list_users()

    while page:
        for user in page.users:
            
            users.append({
                "uid": user.uid,
                "email": user.email,
                "email_verified": user.email_verified,
                "display_name": user.display_name,
                "photo_url": user.photo_url,
                "last_sign_in_timestamp": user.tokens_valid_after_timestamp,
                "created_at": user.user_metadata.creation_timestamp
            })
        
        
        page = page.get_next_page()

    
    return jsonify(users), 200

What could be the problem?

Firebase email confirmation is not working

I have set up email sending in Firebase Auth. The email arrives, but after clicking the generated link, the email_verified flag remains false.

Here is my code for sending the email.

    email_verify_response = requests.post(
        f'https://identitytoolkit.googleapis/v1/accounts:sendOobCode?key={FIREBASE_API_KEY}',
        json={"requestType": "VERIFY_EMAIL", "idToken": id_token}
    )
    email_verify_data = email_verify_response.json()

    if 'error' in email_verify_data:
        print("Ошибка при отправке email для подтверждения")
        return firebase_error_response(email_verify_data['error']['message'], 503)
    
    print("Email для подтверждения отправлен")

Here is the code for fetching the users (I run it after clicking the link to check the flag).

    users = []
    
    
    page = auth.list_users()

    while page:
        for user in page.users:
            
            users.append({
                "uid": user.uid,
                "email": user.email,
                "email_verified": user.email_verified,
                "display_name": user.display_name,
                "photo_url": user.photo_url,
                "last_sign_in_timestamp": user.tokens_valid_after_timestamp,
                "created_at": user.user_metadata.creation_timestamp
            })
        
        
        page = page.get_next_page()

    
    return jsonify(users), 200

What could be the problem?

Share Improve this question asked Nov 17, 2024 at 12:07 MaximMaxim 274 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Once an ID token has been minted it is immutable. So the email_verified claim will only be updated once a new ID token is minted.

In the client-side code that gets the ID token, you can force getting a new token on the user object. If you send that token to the server, the email_verified will then show the up-to-date value.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745636264a4637410.html

相关推荐

  • python - Firebase email confirmation is not working - Stack Overflow

    Firebase email confirmation is not workingI have set up email sending in Firebase Auth.The email arri

    2小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信