<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need Help with Tracking Script Execution in Meraki Dashboard  for team Environment in Network Platform API</title>
    <link>https://community.cisco.com/t5/network-platform-api/need-help-with-tracking-script-execution-in-meraki-dashboard-for/m-p/5401241#M621</link>
    <description>&lt;P&gt;with this i solved my problem&lt;/P&gt;&lt;P&gt;Thanks for idea of logging&lt;/P&gt;&lt;P&gt;# This script implements logging for tracking user actions and changes.&lt;BR /&gt;# It stores a backup before and after any modifications to maintain data integrity.&lt;BR /&gt;# The log records details such as the user performing the action and the specific changes made.&lt;/P&gt;</description>
    <pubDate>Wed, 02 Apr 2025 23:19:24 GMT</pubDate>
    <dc:creator>srajiwate</dc:creator>
    <dc:date>2025-04-02T23:19:24Z</dc:date>
    <item>
      <title>Need Help with Tracking Script Execution in Meraki Dashboard  for team Environment</title>
      <link>https://community.cisco.com/t5/network-platform-api/need-help-with-tracking-script-execution-in-meraki-dashboard-for/m-p/5401238#M618</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;I'm currently working on a script that interacts with the Meraki API to manage policy object groups across multiple organizations. The script is designed to fetch the API key from Azure Key Vault and perform various operations. Here's a brief overview of the script:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;-----------------------------------&lt;BR /&gt;import requests&lt;BR /&gt;import pandas as pd&lt;BR /&gt;from azure.identity import DefaultAzureCredential&lt;BR /&gt;from azure.keyvault.secrets import SecretClient&lt;/P&gt;&lt;P&gt;# Initialize Azure Key Vault client&lt;BR /&gt;key_vault_name = "&amp;lt;Your-KeyVault-Name&amp;gt;"&lt;BR /&gt;KVUri = f"https://{key_vault_name}.vault.azure.net"&lt;BR /&gt;credential = DefaultAzureCredential()&lt;BR /&gt;client = SecretClient(vault_url=KVUri, credential=credential)&lt;/P&gt;&lt;P&gt;# Fetch the API key from Azure Key Vault&lt;BR /&gt;api_key = client.get_secret("&amp;lt;Your-Secret-Name&amp;gt;").value&lt;/P&gt;&lt;P&gt;# Define the API endpoint and headers&lt;BR /&gt;base_url = "&lt;A href="https://api.meraki.com/api/v1/organizations/{organizationId}/policyObjects/groups" target="_blank" rel="nofollow noopener noreferrer"&gt;https://api.meraki.com/api/v1/organizations/{organizationId}/policyObjects/groups&lt;/A&gt;"&lt;BR /&gt;headers = {&lt;BR /&gt;'Authorization': f'Bearer {api_key}',&lt;BR /&gt;'Accept': 'application/json'&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Read organization IDs from Excel file&lt;BR /&gt;excel_file = '&amp;lt;Path-to-Your-Excel-File&amp;gt;' # Replace with your Excel file path&lt;BR /&gt;df = pd.read_excel(excel_file)&lt;/P&gt;&lt;P&gt;# Prompt for user ID&lt;BR /&gt;user_id = input("Enter your user ID: ")&lt;/P&gt;&lt;P&gt;# Iterate over each organization ID&lt;BR /&gt;for org_id in df['organizationId']:&lt;BR /&gt;print(f"\nProcessing organization ID: {org_id} by user: {user_id}")&lt;BR /&gt;org_base_url = base_url.replace("{organizationId}", str(org_id))&lt;/P&gt;&lt;P&gt;# Fetch the policy object groups&lt;BR /&gt;response = requests.get(org_base_url, headers=headers)&lt;BR /&gt;if response.status_code == 200:&lt;BR /&gt;policy_groups = response.json()&lt;BR /&gt;if policy_groups:&lt;BR /&gt;print("Policy Object Groups:")&lt;BR /&gt;for idx, group in enumerate(policy_groups):&lt;BR /&gt;print(f"{idx + 1}. Name: {group['name']}, ID: {group['id']}")&lt;/P&gt;&lt;P&gt;# Ask for confirmation&lt;BR /&gt;to_delete = input(f"Enter the numbers of the groups you want to delete for organization ID {org_id}, separated by commas: ")&lt;BR /&gt;to_delete_ids = [policy_groups[int(num) - 1]['id'] for num in to_delete.split(",")]&lt;/P&gt;&lt;P&gt;# Delete the selected groups&lt;BR /&gt;for group_id in to_delete_ids:&lt;BR /&gt;delete_url = f"{org_base_url}/{group_id}"&lt;BR /&gt;delete_response = requests.delete(delete_url, headers=headers)&lt;BR /&gt;if delete_response.status_code == 204:&lt;BR /&gt;print(f"Deleted group with ID: {group_id} by user: {user_id}")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Failed to delete group with ID: {group_id} by user: {user_id}")&lt;BR /&gt;else:&lt;BR /&gt;print("No policy object groups found.")&lt;BR /&gt;else:&lt;BR /&gt;print(f"Failed to fetch policy object groups for organization ID: {org_id} by user: {user_id}")&lt;/P&gt;&lt;P&gt;print("Script completed.")&lt;/P&gt;&lt;P&gt;-------------------------------------&lt;BR /&gt;The Issue: The script works perfectly, but since the API key is associated with my Meraki account, all actions are logged under my name in the Meraki dashboard. This makes it difficult to track which team member (we are a team of 10) executed the script.&lt;/P&gt;&lt;P&gt;Additional Challenge: We can only create two API keys per profile in the Meraki dashboard. Additionally, most of our team members use Single Sign-On (SSO) accounts, which do not support API key generation.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;What I've Tried:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Prompting for user ID at the start of the script to log who is running it.&lt;/LI&gt;&lt;LI&gt;Azure CLI login at start before executing the script to authorize from azure to access keyvault. &lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;What I'm Looking For:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Best practices for managing API keys and tracking script execution in a team environment.&lt;/LI&gt;&lt;LI&gt;Accounting of script execution like script1 was executed by person1 and script 2 execute by person2&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;BR /&gt;Any help or insights would be greatly appreciated!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2025 09:02:42 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/need-help-with-tracking-script-execution-in-meraki-dashboard-for/m-p/5401238#M618</guid>
      <dc:creator>srajiwate</dc:creator>
      <dc:date>2025-03-18T09:02:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Tracking Script Execution in Meraki Dashboard  for team Environment</title>
      <link>https://community.cisco.com/t5/network-platform-api/need-help-with-tracking-script-execution-in-meraki-dashboard-for/m-p/5401239#M619</link>
      <description>&lt;P&gt;This might help give you some idea of ​​good practices.&lt;/P&gt;&lt;P&gt;&lt;A href="https://blog.pixelfreestudio.com/best-practices-for-secure-api-key-management/" target="_blank" rel="nofollow noopener noreferrer"&gt;Best Practices for Secure API Key Management&lt;/A&gt;&lt;/P&gt;&lt;P&gt;One idea is to implement audit logging within your script to record who ran the script and what actions were performed. This could include timestamps, user IDs, and details of the operations.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2025 18:00:17 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/need-help-with-tracking-script-execution-in-meraki-dashboard-for/m-p/5401239#M619</guid>
      <dc:creator>aleabrahao</dc:creator>
      <dc:date>2025-03-18T18:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Tracking Script Execution in Meraki Dashboard  for team Environment</title>
      <link>https://community.cisco.com/t5/network-platform-api/need-help-with-tracking-script-execution-in-meraki-dashboard-for/m-p/5401240#M620</link>
      <description>&lt;P&gt;Depends where you want to log the usage.&lt;/P&gt;&lt;P&gt;Append to a local log file, or send to a log server for instance.&lt;/P&gt;&lt;P&gt;If you want it logged within the Meraki environment, I think you could use MERAKI_PYTHON_SDK_CALLER&lt;/P&gt;&lt;P&gt;Set it to some string identifying the user on the system running the script, and it'll append to the &lt;SPAN&gt;userAgent string in the API request. &lt;/SPAN&gt;&lt;SPAN&gt;Obviously you should not be sharing logins on the system(s) running your scripts.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You can then use the getOrganizationApiRequests endpoint to get the API usage data, which includes userAgent.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;See here for MERAKI_PYTHON_SDK_CALLER usage rules...&lt;/P&gt;&lt;P class=""&gt;&lt;A href="https://github.com/meraki/dashboard-api-python/blob/main/meraki/config.py" target="_blank" rel="noopener nofollow noreferrer"&gt;https://github.com/meraki/dashboard-api-python/blob/main/meraki/config.py&lt;/A&gt;&lt;/P&gt;&lt;P class=""&gt;...to play nice, perhaps put the ID as a simple numeric in the OptionalVersionNumber.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Mar 2025 18:31:22 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/need-help-with-tracking-script-execution-in-meraki-dashboard-for/m-p/5401240#M620</guid>
      <dc:creator>sungod</dc:creator>
      <dc:date>2025-03-18T18:31:22Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with Tracking Script Execution in Meraki Dashboard  for team Environment</title>
      <link>https://community.cisco.com/t5/network-platform-api/need-help-with-tracking-script-execution-in-meraki-dashboard-for/m-p/5401241#M621</link>
      <description>&lt;P&gt;with this i solved my problem&lt;/P&gt;&lt;P&gt;Thanks for idea of logging&lt;/P&gt;&lt;P&gt;# This script implements logging for tracking user actions and changes.&lt;BR /&gt;# It stores a backup before and after any modifications to maintain data integrity.&lt;BR /&gt;# The log records details such as the user performing the action and the specific changes made.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 23:19:24 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-platform-api/need-help-with-tracking-script-execution-in-meraki-dashboard-for/m-p/5401241#M621</guid>
      <dc:creator>srajiwate</dc:creator>
      <dc:date>2025-04-02T23:19:24Z</dc:date>
    </item>
  </channel>
</rss>

