cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3035
Views
1
Helpful
2
Replies

Python getting UserID of Guest User with merakiAuthUsers query mail address

DennisWerner
Community Member

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

Accepted Solutions

RomanMD
Level 6
Level 6

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
Level 6
Level 6

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)

Perfect, Thank you so much ! 🙂

It works great!