-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added snippets for email action links API (#264)
* Added snippets for email action links API * Fixing a lint error; Fixing a regression caused by googleapis/google-auth-library-python#324 * Fixing order of exported methods * Applying feedback from docs team; Updating snippets based on code review comments
- Loading branch information
1 parent
e48e2b8
commit 5a76058
Showing
3 changed files
with
54 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -587,6 +587,54 @@ def import_without_password(): | |
print('Error importing users:', error) | ||
# [END import_without_password] | ||
|
||
def init_action_code_settings(): | ||
# [START init_action_code_settings] | ||
action_code_settings = auth.ActionCodeSettings( | ||
url='https://www.example.com/checkout?cartId=1234', | ||
handle_code_in_app=True, | ||
ios_bundle_id='com.example.ios', | ||
android_package_name='com.example.android', | ||
android_install_app=True, | ||
android_minimum_version='12', | ||
dynamic_link_domain='coolapp.page.link', | ||
) | ||
# [END init_action_code_settings] | ||
return action_code_settings | ||
|
||
def password_reset_link(): | ||
action_code_settings = init_action_code_settings() | ||
# [START password_reset_link] | ||
email = '[email protected]' | ||
link = auth.generate_password_reset_link(email, action_code_settings) | ||
# Construct password reset email from a template embedding the link, and send | ||
# using a custom SMTP server. | ||
send_custom_email(email, link) | ||
# [END password_reset_link] | ||
|
||
def email_verification_link(): | ||
action_code_settings = init_action_code_settings() | ||
# [START email_verification_link] | ||
email = '[email protected]' | ||
link = auth.generate_email_verification_link(email, action_code_settings) | ||
# Construct email from a template embedding the link, and send | ||
# using a custom SMTP server. | ||
send_custom_email(email, link) | ||
# [END email_verification_link] | ||
|
||
def sign_in_with_email_link(): | ||
action_code_settings = init_action_code_settings() | ||
# [START sign_in_with_email_link] | ||
email = '[email protected]' | ||
link = auth.generate_sign_in_with_email_link(email, action_code_settings) | ||
# Construct email from a template embedding the link, and send | ||
# using a custom SMTP server. | ||
send_custom_email(email, link) | ||
# [END sign_in_with_email_link] | ||
|
||
def send_custom_email(email, link): | ||
del email | ||
del link | ||
|
||
initialize_sdk_with_service_account() | ||
initialize_sdk_with_application_default() | ||
#initialize_sdk_with_refresh_token() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters