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 badges1 Answer
Reset to default 0Once 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
评论列表(0条)