When I used this for portal it worked but for ArcGIS Online it doesn't return the email.
source = GIS("https://meftonline.arcgisonline.com/home/index.html", "username", "password", verify_cert=False)
start = 0
lenght_searchresult = 100
while lenght_searchresult == 100:
source_users = source.users.advanced_search(query='!esri_ & !portaladmin', start = start, max_users = 100)
list_users = source_users.get('results')
lenght_searchresult = len(list_users)
start = start + 100
for user in list_users:
print(user.username)
This should be a simpler way to do it:
# Connect to GIS
source = GIS(url, username, password)
# Get all users in GIS
source_users = source.users.search('!esri_ & !portaladmin',max_users=99999)
# Print username
for user in source_users:
print(f"{user.username} | {user.email}")