<?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: XMC API Authentication in ExtremeCloud IQ- Site Engine Management Center</title>
    <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99769#M10114</link>
    <description>&lt;P&gt;on GitHub is a Python class available offload all the pain of fiddling with the API detail.&lt;BR /&gt;&lt;A href="https://github.com/extremenetworks/ExtremeScripting/tree/master/XMC_XIQ-SE/nbi_clients" target="_blank"&gt;ExtremeScripting/XMC_XIQ-SE/nbi_clients at master · extremenetworks/ExtremeScripting (github.com)&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Mar 2024 12:42:53 GMT</pubDate>
    <dc:creator>Markus_Nikulski</dc:creator>
    <dc:date>2024-03-25T12:42:53Z</dc:date>
    <item>
      <title>XMC API Authentication</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99761#M10111</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I was exploring the API functionallity of the Extreme Management Center through the built in nbi explorer, since we are migrating to the newer XIQ Site Engine it would be useful to be able to transfer data between them.&lt;/P&gt;&lt;P&gt;I did create a simple python script just to verify basic access to the API.&lt;/P&gt;&lt;P&gt;I am getting the access token from the ems, but when trying to post the query to the /nbi/graphql endpoint, i am getting a 401 Unauthorized back. I even tried including the same credentials as i used for aquiring the initial access_token, but no luck there either.&lt;/P&gt;&lt;P&gt;The query in question:&lt;/P&gt;&lt;P&gt;query {network {devices { up ip sysName siteData { siteId siteName location }}}}&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 08:45:33 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99761#M10111</guid>
      <dc:creator>Johnny69</dc:creator>
      <dc:date>2024-03-25T08:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: XMC API Authentication</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99766#M10112</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;Please check the Administration --&amp;gt; Client API access to make sure you have configured API access accordingly.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I would also recommend looking into use of this tool:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/extremenetworks/ExtremeScripting/blob/master/XMC_XIQ-SE/nbi_clients/Python3/XMC_NBI.py" target="_blank"&gt;https://github.com/extremenetworks/ExtremeScripting/blob/master/XMC_XIQ-SE/nbi_clients/Python3/XMC_NBI.py&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/extremenetworks/ExtremeScripting/blob/master/XMC_XIQ-SE/nbi_clients/README.md" target="_blank"&gt;https://github.com/extremenetworks/ExtremeScripting/blob/master/XMC_XIQ-SE/nbi_clients/README.md&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Some modification will be necessary to get it to point to your XIQ-SE, but I've used it to get API access remotely.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;BR /&gt;-Ryan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 12:29:10 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99766#M10112</guid>
      <dc:creator>Ryan_Yacobucci</dc:creator>
      <dc:date>2024-03-25T12:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: XMC API Authentication</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99769#M10114</link>
      <description>&lt;P&gt;on GitHub is a Python class available offload all the pain of fiddling with the API detail.&lt;BR /&gt;&lt;A href="https://github.com/extremenetworks/ExtremeScripting/tree/master/XMC_XIQ-SE/nbi_clients" target="_blank"&gt;ExtremeScripting/XMC_XIQ-SE/nbi_clients at master · extremenetworks/ExtremeScripting (github.com)&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 12:42:53 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99769#M10114</guid>
      <dc:creator>Markus_Nikulski</dc:creator>
      <dc:date>2024-03-25T12:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: XMC API Authentication</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99772#M10115</link>
      <description>&lt;P&gt;just to answer your question. The token you got during login have to be used like this for all the GraphQL queries until the token expired.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Markus_Nikulski_0-1711371842841.png" style="width: 400px;"&gt;&lt;img src="https://community.extremenetworks.com/t5/image/serverpage/image-id/7043i20374B7490227EE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Markus_Nikulski_0-1711371842841.png" alt="Markus_Nikulski_0-1711371842841.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Markus_Nikulski_1-1711371881905.png" style="width: 400px;"&gt;&lt;img src="https://community.extremenetworks.com/t5/image/serverpage/image-id/7044iAFA019FA98F37C2A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Markus_Nikulski_1-1711371881905.png" alt="Markus_Nikulski_1-1711371881905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 13:04:50 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99772#M10115</guid>
      <dc:creator>Markus_Nikulski</dc:creator>
      <dc:date>2024-03-25T13:04:50Z</dc:date>
    </item>
    <item>
      <title>Re: XMC API Authentication</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99781#M10116</link>
      <description>&lt;P&gt;In XMC i have checked the "northbound API" for the client.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached the script i am using to test api access. Did i miss something?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import requests
import json
from urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(category = InsecureRequestWarning)

host='https://&amp;lt;redacted&amp;gt;:8443'
nbi_uri = host + '/nbi/graphql'

token_url = 'https://&amp;lt;redacted&amp;gt;:8443/oauth/token/access-token?grant_type=client_credentials'
client_id='&amp;lt;redacted&amp;gt;'
secret='&amp;lt;redacted&amp;gt;'
auth_headers = { "Content-Type":"application/x-www-form-urlencoded" }
response = requests.post(token_url,auth=(client_id,secret),headers=auth_headers,verify=False,timeout=3)
result = response.json()

access_token = result['access_token']
nbi_query = 'network { devices { up ip sysName siteData { siteId siteName location } } }'
s = requests.Session()
s.verify = False
s.timeout = 5
s.headers.update = ({"Accept":"application/json",
                        "Content-type": "application/json",
                        "Cache-Control":"no-cache",
                        "Authorization": "Bearer " + access_token,
                        })
res = s.post(nbi_uri,json={'query':nbi_query})
print(res)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 08:34:49 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99781#M10116</guid>
      <dc:creator>Johnny69</dc:creator>
      <dc:date>2024-03-26T08:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: XMC API Authentication</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99789#M10117</link>
      <description>&lt;P&gt;I still not get why you are not using the existing Python class.&lt;/P&gt;&lt;P&gt;However I found two issues in your code.&lt;BR /&gt;1. if you using a object oriented programming like a session in requests, you cannot update the header like you do.&lt;BR /&gt;Upper example is your wrong one, the lower one is the correct way to do it.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Markus_Nikulski_2-1711465126217.png" style="width: 400px;"&gt;&lt;img src="https://community.extremenetworks.com/t5/image/serverpage/image-id/7047i658B6ACF9FED36F7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Markus_Nikulski_2-1711465126217.png" alt="Markus_Nikulski_2-1711465126217.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. you&amp;nbsp;&lt;SPAN&gt;nbi_query&amp;nbsp;&lt;/SPAN&gt;is malformed according to the documentation. The XIX-SE tolerate such malformed call, but is better to have it clean. The outer curly brackets are missing.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Markus_Nikulski_1-1711465072587.png" style="width: 400px;"&gt;&lt;img src="https://community.extremenetworks.com/t5/image/serverpage/image-id/7046i9585E0D099E1946F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Markus_Nikulski_1-1711465072587.png" alt="Markus_Nikulski_1-1711465072587.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 14:59:02 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99789#M10117</guid>
      <dc:creator>Markus_Nikulski</dc:creator>
      <dc:date>2024-03-26T14:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: XMC API Authentication</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99791#M10118</link>
      <description>&lt;P&gt;I still not get, why you not use the existing Python class.&lt;/P&gt;&lt;P&gt;However, you added a equal sign where no equal &amp;nbsp;sign should be&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Markus_Nikulski_0-1711465846423.png" style="width: 400px;"&gt;&lt;img src="https://community.extremenetworks.com/t5/image/serverpage/image-id/7048i433CF04F64A99449/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Markus_Nikulski_0-1711465846423.png" alt="Markus_Nikulski_0-1711465846423.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 15:10:54 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99791#M10118</guid>
      <dc:creator>Markus_Nikulski</dc:creator>
      <dc:date>2024-03-26T15:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: XMC API Authentication</title>
      <link>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99806#M10120</link>
      <description>&lt;P&gt;Thank you very much, i corrected the two issues you mentioned. I am now able to pull the data from the API, Many thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2024 12:43:00 GMT</pubDate>
      <guid>https://community.extremenetworks.com/t5/extremecloud-iq-site-engine/xmc-api-authentication/m-p/99806#M10120</guid>
      <dc:creator>Johnny69</dc:creator>
      <dc:date>2024-03-27T12:43:00Z</dc:date>
    </item>
  </channel>
</rss>

