Python getting UserID of Guest User with merakiAuthUsers query mail address

Solved
DennisWerner
Just browsing

Python getting UserID of Guest User with merakiAuthUsers query mail address

Hi,

i am looking for a possibility to query the username of a guest account not the User ID.

I have the following code where i get all users, but i can not find or filter a specific User by filtering the username (mail address) maybe someone can help getting the meraki_auth_user_id by filtering the mail address?

 

import meraki


API_KEY = 'xxxxxxxxxxxxxx'
dashboard = meraki.DashboardAPI(API_KEY)
network_id = 'xxxxxxxxxxxxxxx'

response = dashboard.networks.getNetworkMerakiAuthUsers(
network_id
)

print (response)

 

As result, i need the ID of the User by searching after the mail address.

 

Thanks for any help or advise.

Dennis

1 Accepted Solution
RomanMD
Building a reputation

The most obvious way is to loop thru the user list:

 

 

import meraki

API_KEY = 'xxxxxxxxxxxxxx'
dashboard = meraki.DashboardAPI(API_KEY)
network_id = 'xxxxxxxxxxxxxxx'
required_username = 'myuser@name.com'

users = dashboard.networks.getNetworkMerakiAuthUsers(
network_id
)

for user in users:
    if user["email"] == required_username:
        pprint(user)

 

 

Pythonic way would be to substitute the for loop with list comprehension:

 

myuser = [user for user in users if user["email"]==required_username]
pprint(myuser)

 

 

View solution in original post

2 Replies 2
RomanMD
Building a reputation

The most obvious way is to loop thru the user list:

 

 

import meraki

API_KEY = 'xxxxxxxxxxxxxx'
dashboard = meraki.DashboardAPI(API_KEY)
network_id = 'xxxxxxxxxxxxxxx'
required_username = 'myuser@name.com'

users = dashboard.networks.getNetworkMerakiAuthUsers(
network_id
)

for user in users:
    if user["email"] == required_username:
        pprint(user)

 

 

Pythonic way would be to substitute the for loop with list comprehension:

 

myuser = [user for user in users if user["email"]==required_username]
pprint(myuser)

 

 

DennisWerner
Just browsing

Perfect, Thank you so much ! 🙂

It works great!

Get notified when there are additional replies to this discussion.