Hello
I am building an OAuth for my users so they can get the list of users which have a license per country.
I am running the code below, it is working fine to reach page 1 and 2, but I am not able to reach page 3 to 7.
I have launched debug in Pycharm, but I have been with my head in the code for hours…
def get_users(access_token):
headers = {
'Authorization': f'Bearer {access_token}',
'Content-Type': 'application/json'
}
URL_USERS = "https://api.zoom.us/v2/users?status=active&page_size=300"
next_page_token = ""
page_number = 1
users_per_location = {}
while True:
if next_page_token:
params = {'page_token': next_page_token, "page_number": page_number}
response = requests.get(URL_USERS, headers=headers, params=params)
else:
response = requests.get(URL_USERS, headers=headers)
page_number += 1
response_json = response.json()
for user in response_json['users']:
if user['type'] == 2:
try:
if user['timezone'].split("/")[1] in users_per_location:
users_per_location[user['timezone'].split("/")[1]] += 1
else:
users_per_location[user['timezone'].split("/")[1]] = 1
except IndexError:
pass
if 'next_page_token' in response_json:
next_page_token = response_json['next_page_token']
else:
break
print(users_per_location)
return users_per_location
I have checked some other posts in this forum, and Zoom devs took example where they dont use “page_number” in parameters (but in my case it prevents me from breaking the while loop)
Any thoughts?