@@ -521,6 +521,62 @@ def _token_from_auth_url(self, url):
521
521
'type' : 'id_token' ,
522
522
'value' : request_object .json ()['id_token' ],
523
523
}
524
+
525
+ def change_email (self , id_token , email ):
526
+ """ Changes a user's email
527
+
528
+ | For more details:
529
+ | `Firebase Auth REST API | section-change-email`_
530
+
531
+ .. _Firebase Auth REST API | section-change-email: https://firebase.google.com/docs/reference/rest/auth#section-change-email
532
+
533
+ :type id_token: str
534
+ :param id_token: A Firebase Auth ID token for the user.
535
+
536
+ :type email: str
537
+ :param email: User's new email.
538
+
539
+ :return: UserInfo and Firebase Auth Tokens.
540
+ :rtype: dict
541
+ """
542
+
543
+ request_ref = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key={0}" .format (self .api_key )
544
+
545
+ headers = {"content-type" : "application/json; charset=UTF-8" }
546
+ data = json .dumps ({"idToken" : id_token , "email" : email , "returnSecureToken" : True })
547
+ request_object = self .requests .post (request_ref , headers = headers , data = data )
548
+
549
+ raise_detailed_error (request_object )
550
+
551
+ return request_object .json ()
552
+
553
+ def change_password (self , id_token , password ):
554
+ """ Changes a user's password
555
+
556
+ | For more details:
557
+ | `Firebase Auth REST API | section-change-password`_
558
+
559
+ .. _Firebase Auth REST API | section-change-password: https://firebase.google.com/docs/reference/rest/auth#section-change-password
560
+
561
+ :type id_token: str
562
+ :param id_token: A Firebase Auth ID token for the user.
563
+
564
+ :type password: str
565
+ :param password: User's new password.
566
+
567
+ :return: UserInfo and Firebase Auth Tokens.
568
+ :rtype: dict
569
+ """
570
+
571
+ request_ref = "https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key={0}" .format (self .api_key )
572
+
573
+ headers = {"content-type" : "application/json; charset=UTF-8" }
574
+ data = json .dumps ({"idToken" : id_token , "password" : password , "returnSecureToken" : True })
575
+ request_object = self .requests .post (request_ref , headers = headers , data = data )
576
+
577
+ raise_detailed_error (request_object )
578
+
579
+ return request_object .json ()
524
580
525
581
def update_profile (self , id_token , display_name = None , photo_url = None , delete_attribute = None ):
526
582
""" Update a user's profile (display name / photo URL).
0 commit comments