<?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 Using PowerShell to Generate an OAuth Token for Cisco API Console in Services Discussions</title>
    <link>https://community.cisco.com/t5/services-discussions/using-powershell-to-generate-an-oauth-token-for-cisco-api/m-p/3428655#M11</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;&lt;SPAN style="font-family: 'times new roman', times;"&gt;I know there are examples of&lt;/SPAN&gt; how to Gen an OAuth token in Python &amp;amp; CURL but I like using PowerShell so here is a script I wrote to generate an OAuth Token.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: 16px; color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;1: Access the Cisco API console &lt;/SPAN&gt;at &lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;&lt;A href="https://apiconsole.cisco.com/" style="color: #0366d6;"&gt;https://apiconsole.cisco.com&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 16px; color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;2: Login with your CCO credentials (login is only available to registered Cisco customers and partners).&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 16px; color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;3: Register your application and obtain your client credentials.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 16px; color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;4: Once you register your application and obtain your client ID and client secret, the next step is to obtain an authorization token. Authorization tokens in the Cisco PSIRT openVuln API are valid for one (1) hour.&amp;nbsp; The Powershell script below will tell the API service to grant you an access_token.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;# Clear all Used Variables&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$url&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;''&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$postdata&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;''&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$content&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;''&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$auth_response&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;''&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$url&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;'&lt;A class="jive-link-external-small" href="https://cloudsso.cisco.com/as/token.oauth2" rel="nofollow" target="_blank"&gt;https://cloudsso.cisco.com/as/token.oauth2&lt;/A&gt;'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$postdata&lt;/SPAN&gt;= @{client_id=&lt;SPAN style="color: #993300;"&gt;'INSERT_YOUR_CLIENT_ID'&lt;/SPAN&gt;;client_secret=&lt;SPAN style="color: #993300;"&gt;'INSERT_YOUR_CLIENT_SECRET'&lt;/SPAN&gt;;grant_type=&lt;SPAN style="color: #993300;"&gt;'client_credentials'&lt;/SPAN&gt;}&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$content&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;'application/x-www-form-urlencoded'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$auth_response&lt;/SPAN&gt;=&lt;SPAN style="color: #0000ff;"&gt;Invoke-RestMethod&lt;/SPAN&gt; -URI &lt;SPAN style="color: #ff0000;"&gt;$url&lt;/SPAN&gt; -Method &lt;SPAN style="color: #800080;"&gt;Post&lt;/SPAN&gt; -Body &lt;SPAN style="color: #ff0000;"&gt;$postdata&lt;/SPAN&gt; -ContentType &lt;SPAN style="color: #ff0000;"&gt;$content&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;Write-Host&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;$auth_response&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;The response should look like this.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;IMG __jive_id="112804" alt="response.jpg" class="image-1 jive-image" src="https://community.cisco.com/legacyfs/online/fusion/112808_response.jpg" style="height: 57px; width: 620px;" /&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 12pt; font-family: 'times new roman', times;"&gt;Be sure to note the access_token you received!&amp;nbsp;&amp;nbsp;&amp;nbsp; You will need it in subsequent queries.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 12pt; font-family: 'times new roman', times;"&gt;Also be sure to remember that this access_token is ONLY valid for one hour. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 12pt; font-family: 'times new roman', times;"&gt;Please comment and rate this post!&amp;nbsp;&amp;nbsp; Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 26 Oct 2017 16:11:19 GMT</pubDate>
    <dc:creator>Tim Glen</dc:creator>
    <dc:date>2017-10-26T16:11:19Z</dc:date>
    <item>
      <title>Using PowerShell to Generate an OAuth Token for Cisco API Console</title>
      <link>https://community.cisco.com/t5/services-discussions/using-powershell-to-generate-an-oauth-token-for-cisco-api/m-p/3428655#M11</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;&lt;SPAN style="font-family: 'times new roman', times;"&gt;I know there are examples of&lt;/SPAN&gt; how to Gen an OAuth token in Python &amp;amp; CURL but I like using PowerShell so here is a script I wrote to generate an OAuth Token.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: 16px; color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;1: Access the Cisco API console &lt;/SPAN&gt;at &lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;&lt;A href="https://apiconsole.cisco.com/" style="color: #0366d6;"&gt;https://apiconsole.cisco.com&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 16px; color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;2: Login with your CCO credentials (login is only available to registered Cisco customers and partners).&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 16px; color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;3: Register your application and obtain your client credentials.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 16px; color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px;"&gt;&lt;SPAN style="font-family: 'times new roman', times; font-size: 12pt;"&gt;4: Once you register your application and obtain your client ID and client secret, the next step is to obtain an authorization token. Authorization tokens in the Cisco PSIRT openVuln API are valid for one (1) hour.&amp;nbsp; The Powershell script below will tell the API service to grant you an access_token.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #008000;"&gt;# Clear all Used Variables&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$url&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;''&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$postdata&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;''&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$content&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;''&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$auth_response&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;''&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$url&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;'&lt;A class="jive-link-external-small" href="https://cloudsso.cisco.com/as/token.oauth2" rel="nofollow" target="_blank"&gt;https://cloudsso.cisco.com/as/token.oauth2&lt;/A&gt;'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$postdata&lt;/SPAN&gt;= @{client_id=&lt;SPAN style="color: #993300;"&gt;'INSERT_YOUR_CLIENT_ID'&lt;/SPAN&gt;;client_secret=&lt;SPAN style="color: #993300;"&gt;'INSERT_YOUR_CLIENT_SECRET'&lt;/SPAN&gt;;grant_type=&lt;SPAN style="color: #993300;"&gt;'client_credentials'&lt;/SPAN&gt;}&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$content&lt;/SPAN&gt;=&lt;SPAN style="color: #993300;"&gt;'application/x-www-form-urlencoded'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #ff0000;"&gt;$auth_response&lt;/SPAN&gt;=&lt;SPAN style="color: #0000ff;"&gt;Invoke-RestMethod&lt;/SPAN&gt; -URI &lt;SPAN style="color: #ff0000;"&gt;$url&lt;/SPAN&gt; -Method &lt;SPAN style="color: #800080;"&gt;Post&lt;/SPAN&gt; -Body &lt;SPAN style="color: #ff0000;"&gt;$postdata&lt;/SPAN&gt; -ContentType &lt;SPAN style="color: #ff0000;"&gt;$content&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #0000ff;"&gt;Write-Host&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;$auth_response&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;The response should look like this.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;IMG __jive_id="112804" alt="response.jpg" class="image-1 jive-image" src="https://community.cisco.com/legacyfs/online/fusion/112808_response.jpg" style="height: 57px; width: 620px;" /&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 12pt; font-family: 'times new roman', times;"&gt;Be sure to note the access_token you received!&amp;nbsp;&amp;nbsp;&amp;nbsp; You will need it in subsequent queries.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 12pt; font-family: 'times new roman', times;"&gt;Also be sure to remember that this access_token is ONLY valid for one hour. &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 12pt; font-family: 'times new roman', times;"&gt;Please comment and rate this post!&amp;nbsp;&amp;nbsp; Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 26 Oct 2017 16:11:19 GMT</pubDate>
      <guid>https://community.cisco.com/t5/services-discussions/using-powershell-to-generate-an-oauth-token-for-cisco-api/m-p/3428655#M11</guid>
      <dc:creator>Tim Glen</dc:creator>
      <dc:date>2017-10-26T16:11:19Z</dc:date>
    </item>
  </channel>
</rss>

