<?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 working Authorization Code Flow sample for ArcGIS Maps SDK for JavaScript 4.x in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-working-authorization-code-flow-sample-for/m-p/1665604#M87859</link>
    <description>&lt;P&gt;We finally got it working by using Identity Manager to sign in, then using the Identity Manager event listener. For some reason, the window event listener didn't work for us.&lt;/P&gt;&lt;P&gt;I still think it would be amazing if someone at Esri could set up a fully functioning example of&amp;nbsp;&lt;A href="https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/flows/authorization-code-with-pkce/" target="_self"&gt;Authorization code flow with PKCE&lt;/A&gt;&lt;/P&gt;&lt;P&gt;That is how we need to sign in now, not using &lt;A href="https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/flows/implicit-flow/" target="_self"&gt;Implicit flow&lt;/A&gt;, so give us an example of how it works, start to finish. Thanks!&lt;/P&gt;</description>
    <pubDate>Thu, 13 Nov 2025 19:12:40 GMT</pubDate>
    <dc:creator>MattStayner</dc:creator>
    <dc:date>2025-11-13T19:12:40Z</dc:date>
    <item>
      <title>Need working Authorization Code Flow sample for ArcGIS Maps SDK for JavaScript 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-working-authorization-code-flow-sample-for/m-p/1653183#M87658</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;We're running into issues trying to implement the &lt;STRONG&gt;Authorization Code Flow &lt;/STRONG&gt;for user authentication in our custom web application using the ArcGIS Maps SDK for JavaScript (4.x). We are following the official documentation, specifically: &lt;A href="https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/flows/authorization-code-flow/" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/flows/authorization-code-flow/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;We are trying to implement the full two-step process—receiving the authorization code and manually exchanging it for an access_token—because we need to manage the user session and token refresh on our backend (Node.js/C#/etc.) rather than relying solely on the client-side IdentityManager's implicit flow.&lt;/P&gt;&lt;HR /&gt;&lt;H3&gt;Specific Requests&lt;/H3&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Working Server-Side Exchange Sample:&lt;/STRONG&gt; Does anyone have a fully functional, complete, end-to-end sample project (ideally on GitHub or a code sandbox) that demonstrates the &lt;STRONG&gt;server-side&lt;/STRONG&gt; exchange of the &lt;STRONG&gt;authorization code for an access token&lt;/STRONG&gt; using a standard web framework (e.g., Node.js/Express, Python/Flask, etc.)?&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Registering Server-Side Tokens with IdentityManager:&lt;/STRONG&gt; We also need a clear code sample demonstrating how to take a token received from our server and correctly register it with the IdentityManager on the client-side. We're using IdentityManager.registerToken() but are unsure if we're configuring it correctly for ArcGIS Enterprise.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;HR /&gt;&lt;H3&gt;&lt;span class="lia-unicode-emoji" title=":construction:"&gt;🚧&lt;/span&gt;What We've Tried/Our Setup&lt;/H3&gt;&lt;P&gt;To help with troubleshooting, here is our current setup and the problem we are encountering:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;SDK Version:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt; ArcGIS Maps SDK for JavaScript (4.x)&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;Authentication Flow:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt; Authorization Code Flow with PKCE&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;The Problem:&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt; The client-side part of our application is failing when we try to register the token we get back from our server. We are receiving a &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;TypeError: Cannot read properties of undefined (reading 'toLowerCase')&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt; error in the browser console. This error occurs specifically when we try to &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN class=""&gt;load a secured layer&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class=""&gt; after receiving the token.&lt;/SPAN&gt;&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;SPAN class=""&gt;This seems to indicate that one of the parameters we are passing to a Maps SDK function, likely &lt;/SPAN&gt;&lt;SPAN class=""&gt;IdentityManager.registerToken()&lt;/SPAN&gt;&lt;SPAN class=""&gt;, is not available, or there is some kind of timing issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;H3&gt;&lt;span class="lia-unicode-emoji" title=":globe_with_meridians:"&gt;🌐&lt;/span&gt;ArcGIS Online vs. ArcGIS Enterprise&lt;/H3&gt;&lt;P&gt;We have a key observation that might point to a specific Enterprise configuration issue:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;We have been able to get this entire process working successfully when authenticating against &lt;STRONG&gt;ArcGIS Online&lt;/STRONG&gt;.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;However, the same code and process &lt;STRONG&gt;fails&lt;/STRONG&gt; when we attempt it against our on-premise &lt;STRONG&gt;ArcGIS Enterprise&lt;/STRONG&gt; portal, even after trying multiple user accounts.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Any guidance, links to working code, or insight into common pitfalls when manually implementing the token exchange with ArcGIS Online/Enterprise would be greatly appreciated!&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 25 Sep 2025 17:08:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-working-authorization-code-flow-sample-for/m-p/1653183#M87658</guid>
      <dc:creator>MattStayner</dc:creator>
      <dc:date>2025-09-25T17:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: Need working Authorization Code Flow sample for ArcGIS Maps SDK for JavaScript 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-working-authorization-code-flow-sample-for/m-p/1665536#M87855</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;When using registerToken, does your token follow the typing ?&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#registerToken" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#registerToken&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Pretty sure you are missing “server” from the error. At least something seems missing…&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just a wild guess&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2025 16:41:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-working-authorization-code-flow-sample-for/m-p/1665536#M87855</guid>
      <dc:creator>NicolasGIS</dc:creator>
      <dc:date>2025-11-13T16:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need working Authorization Code Flow sample for ArcGIS Maps SDK for JavaScript 4.x</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-working-authorization-code-flow-sample-for/m-p/1665604#M87859</link>
      <description>&lt;P&gt;We finally got it working by using Identity Manager to sign in, then using the Identity Manager event listener. For some reason, the window event listener didn't work for us.&lt;/P&gt;&lt;P&gt;I still think it would be amazing if someone at Esri could set up a fully functioning example of&amp;nbsp;&lt;A href="https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/flows/authorization-code-with-pkce/" target="_self"&gt;Authorization code flow with PKCE&lt;/A&gt;&lt;/P&gt;&lt;P&gt;That is how we need to sign in now, not using &lt;A href="https://developers.arcgis.com/documentation/security-and-authentication/user-authentication/flows/implicit-flow/" target="_self"&gt;Implicit flow&lt;/A&gt;, so give us an example of how it works, start to finish. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 13 Nov 2025 19:12:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/need-working-authorization-code-flow-sample-for/m-p/1665604#M87859</guid>
      <dc:creator>MattStayner</dc:creator>
      <dc:date>2025-11-13T19:12:40Z</dc:date>
    </item>
  </channel>
</rss>

