<?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 authorization issues error 401 in BIM 360 API Forum</title>
    <link>https://forums.autodesk.com/t5/bim-360-api-forum/authorization-issues-error-401/m-p/12255611#M129</link>
    <description>&lt;P&gt;I seem to keep getting the 401 error not authorized&lt;/P&gt;&lt;P&gt;the ClientID and ClientSecret are correct and went by loads of other steps can't figure out what keeps going wrong&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;// Define your Forge client ID and client secret&lt;BR /&gt;const clientId = '(hidden for security)';&lt;BR /&gt;const clientSecret = '(hidden for security)';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Define global variables&lt;BR /&gt;let accessToken = null;&lt;BR /&gt;let projectId = null;&lt;BR /&gt;let itemId = null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Function to obtain an access token&lt;BR /&gt;async function getAccessToken() {&lt;BR /&gt;try {&lt;BR /&gt;const response = await fetch('&lt;A href="https://developer.api.autodesk.com/authentication/v2/token" target="_blank"&gt;https://developer.api.autodesk.com/authentication/v2/token&lt;/A&gt;', {&lt;BR /&gt;method: 'POST',&lt;BR /&gt;headers: {&lt;BR /&gt;'Content-Type': 'application/x-www-form-urlencoded'&lt;BR /&gt;},&lt;BR /&gt;body: `client_id=${clientId}&amp;amp;client_secret=${clientSecret}&amp;amp;grant_type=client_credentials&amp;amp;scope=data:read`&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;if (!response.ok) {&lt;BR /&gt;throw new Error('Failed to obtain access token');&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const data = await response.json();&lt;BR /&gt;accessToken = data.access_token;&lt;BR /&gt;} catch (error) {&lt;BR /&gt;console.error('Error obtaining access token:', error);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;```&lt;/P&gt;</description>
    <pubDate>Thu, 21 Sep 2023 07:38:31 GMT</pubDate>
    <dc:creator>karsten_duim</dc:creator>
    <dc:date>2023-09-21T07:38:31Z</dc:date>
    <item>
      <title>authorization issues error 401</title>
      <link>https://forums.autodesk.com/t5/bim-360-api-forum/authorization-issues-error-401/m-p/12255611#M129</link>
      <description>&lt;P&gt;I seem to keep getting the 401 error not authorized&lt;/P&gt;&lt;P&gt;the ClientID and ClientSecret are correct and went by loads of other steps can't figure out what keeps going wrong&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;```&lt;/P&gt;&lt;P&gt;// Define your Forge client ID and client secret&lt;BR /&gt;const clientId = '(hidden for security)';&lt;BR /&gt;const clientSecret = '(hidden for security)';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Define global variables&lt;BR /&gt;let accessToken = null;&lt;BR /&gt;let projectId = null;&lt;BR /&gt;let itemId = null;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Function to obtain an access token&lt;BR /&gt;async function getAccessToken() {&lt;BR /&gt;try {&lt;BR /&gt;const response = await fetch('&lt;A href="https://developer.api.autodesk.com/authentication/v2/token" target="_blank"&gt;https://developer.api.autodesk.com/authentication/v2/token&lt;/A&gt;', {&lt;BR /&gt;method: 'POST',&lt;BR /&gt;headers: {&lt;BR /&gt;'Content-Type': 'application/x-www-form-urlencoded'&lt;BR /&gt;},&lt;BR /&gt;body: `client_id=${clientId}&amp;amp;client_secret=${clientSecret}&amp;amp;grant_type=client_credentials&amp;amp;scope=data:read`&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;if (!response.ok) {&lt;BR /&gt;throw new Error('Failed to obtain access token');&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;const data = await response.json();&lt;BR /&gt;accessToken = data.access_token;&lt;BR /&gt;} catch (error) {&lt;BR /&gt;console.error('Error obtaining access token:', error);&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;```&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 07:38:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/bim-360-api-forum/authorization-issues-error-401/m-p/12255611#M129</guid>
      <dc:creator>karsten_duim</dc:creator>
      <dc:date>2023-09-21T07:38:31Z</dc:date>
    </item>
  </channel>
</rss>

