Skip to content

Snippets for new Admin auth features #438

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions snippets/auth/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ def get_user_by_phone_number():
print('Successfully fetched user data: {0}'.format(user.uid))
# [END get_user_by_phone]

def get_user_by_provider_id():
# [START get_user_by_provider_id]
from firebase_admin import auth

user = auth.get_user_by_provider_user_id('google.com', 'google_uid1234')
print('Successfully fetched user data: {0}'.format(user.uid))
# [END get_user_by_provider_id]

def create_user():
# [START create_user]
user = auth.create_user(
Expand Down Expand Up @@ -235,6 +243,26 @@ def update_user(uid):
print('Sucessfully updated user: {0}'.format(user.uid))
# [END update_user]

def update_user_link_federated(uid):
# [START update_user_link_federated]
# Link the user with a federated identity provider (like Google).
user = auth.update_user(
uid,
link_provider=auth.UserProvider(uid='google_uid1234', provider_id='google.com'))

print('Sucessfully updated user: {0}'.format(user.uid))
# [END update_user_link_federated]

def update_user_unlink_federated(uid):
# [START update_user_unlink_federated]
# Unlink the user from a federated identity provider (like Google).
user = auth.update_user(
uid,
delete_provider_ids=['google.com']))

print('Sucessfully updated user: {0}'.format(user.uid))
# [END update_user_unlink_federated]

def delete_user(uid):
# [START delete_user]
auth.delete_user(uid)
Expand Down