Skip to content

Commit

Permalink
Merge pull request #47 from el-vishal/feature/auth_updateProfile
Browse files Browse the repository at this point in the history
Feature/AuthUpdateProfile
Thanks @el-vishal !
  • Loading branch information
nhorvath committed Feb 20, 2022
2 parents b4c9b7d + d3f1d86 commit 916d13f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -79,6 +79,12 @@ user = auth.sign_in_with_email_and_password(email, password)
# Log the user in anonymously
user = auth.sign_in_anonymous()

# Add user info
user = auth.update_profile(display_name, photo_url, delete_attribute)

# Get user info
user = auth.get_account_info()

# Get a reference to the database service
db = firebase.database()

Expand Down
11 changes: 11 additions & 0 deletions pyrebase/pyrebase.py
Expand Up @@ -179,6 +179,17 @@ def delete_user_account(self, id_token):
request_object = requests.post(request_ref, headers=headers, data=data)
raise_detailed_error(request_object)
return request_object.json()

def update_profile(self, id_token, display_name = None, photo_url = None, delete_attribute = None):
"""
https://firebase.google.com/docs/reference/rest/auth#section-update-profile
"""
request_ref = "https://identitytoolkit.googleapis.com/v1/accounts:update?key={0}".format(self.api_key)
headers = {"content-type": "application/json; charset=UTF-8"}
data = json.dumps({"idToken": id_token, "displayName": display_name, "photoURL": photo_url, "deleteAttribute": delete_attribute, "returnSecureToken": True})
request_object = requests.post(request_ref, headers=headers, data=data)
raise_detailed_error(request_object)
return request_object.json()


class Database:
Expand Down

0 comments on commit 916d13f

Please sign in to comment.