This article shows how to ease the process of resending activation emails to inactive users.
Upon a user creation, the user receives an email, requesting it to log in and activate his Sisense user.
If many users are added (bulk/Active Directory) and did not go through the activation, you may want to send them a reminder to activate.
This can be done by initiating a REST API request.
The following script is used to authenticate with your environment, get a list of inactive users and resend them the invitation to activate their Sisense user.
Steps:
1) Download Python and install it on your PC or the Sisense machine (make sure to add python to the PATH to easily initiate installation of directories).
2) Run CMD and type the following commands to add libraries used as part of our solution:
- pip install requests
- pip install json
3) Create a .py file and add the following script to it:
------------------------------------------------------------------------------------
import requests
import json
username = 'admin@email.com' #replace with an admin user's user name
password = 'password' #replace with an admin user's password
Sisense_url = 'http://localhost:8081' #replace with your Sisense url
# Get Auth token
url = Sisense_url+"/api/v1/authentication/login"
payload = "username="+username.replace('@','%40')+"&password="+password
headers = {
'content-type': "application/x-www-form-urlencoded"
}
response = requests.request("POST", url, data=payload, headers=headers)
auth_token = response.json()["access_token"]
auth_token = "Bearer " + auth_token
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': auth_token
}
url = Sisense_url + '/api/v1/users'
resendUrl = Sisense_url + '/api/v1/account/begin_activate'
response = requests.request("GET", url, headers=headers)
users = response.json()
#Sending invites for inactive users
total = 0
for item in users:
active = item["active"]
if not active:
email = item["email"]
payload = '{"email": ' +'"'+email+'"}'
response = requests.request("POST", resendUrl, data=payload, headers=headers)
print(item["email"])
total = total+1
print(total)
------------------------------------------------------------------------------------
4) This process can be automated using a Windows Task Scheduler as well.
That's it!