def _getMailboxes():
users = make_graph_call('https://graph.microsoft.com/v1.0/users', pagination=True)
token_result = client.acquire_token_silent(scope, account=None)
if token_result:
access_token = 'Bearer ' + token_result['access_token']
print('Access token was loaded from cache')
else:
token_result = client.acquire_token_for_client(scopes=scope)
access_token = 'Bearer ' + token_result['access_token']
print('New access token was acquired from Azure AD')
if 'access_token' in token_result:
headers = {
'Authorization': access_token
}
for user in users:
user_id = user['id']
displayName = user['displayName']
jobTitle = user['jobTitle']
mail = user['mail']
url = f'https://graph.microsoft.com/v1.0/users/{user_id}/mailboxSettings'
try:
graph_result = requests.get(url=url, headers=headers).json()
#print(graph_result)
if 'userPurpose' in graph_result:
userPurpose = graph_result.get('userPurpose')
if userPurpose == 'shared':
print(f"shared mailbox {displayName}: {mail}")
except Exception as e:
print(f"Fout bij het ophalen van gegevens: {e}")