Get Setup URLs for New Users in Python

Currently, the only was to get a custom welcome email is through the API. Here is a python script that uses the Python SDK that will return the setup urls for all the users that don’t have a Name, ie they haven’t set up there account.

This solution still requires Users to be created in the UI, and then just don’t select the send setup email

The first thing you need to do is create a Look that has the Name, Email and ID from User Activity. This can be done from your.instance.com/explore/system__activity/user

Once this is done, take the Look ID and add it in the code as the users_look_id. In the code below change it from 60!

import looker_sdk
import urllib3
import json
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

sdk = looker_sdk.init31("looker.ini", "Looker")

my_user = sdk.me().email
print(f'Authenticated as {my_user}')

# CREATE A LOOK IN LOOKER FROM USER ACTIVITY /explore/system__activity/user
# IT NEEDS TO INCLUDE USER ID AND USER NAME
# SET users_look_id TO THE ID OF THE LOOK
users_look_id = 60

# RETURN AN ARRAY OF ALL USERS
user_array = json.loads(sdk.run_look(
    result_format='json',
    look_id=users_look_id))

# LOOP THROUGH THE USERS AND ADD THEM TO THE users_to_setup LIST IF THEY DON'T HAVE A NAME
for i in user_array:
	if(i['user.name'] == None):
		res = sdk.create_user_credentials_email_password_reset(i['user.id'])
		password_reset_url = res.password_reset_url
		setup_url = password_reset_url.replace('password', 'account').replace('reset', 'setup')
		print(f"User {i['user.email']} with ID {i['user.id']} needs to set up using {setup_url}")

# YOU CAN THEN PARSE setup_url TO AN EMAIL !```
4 0 264