<?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 Oauth user is logged in but unable to get token in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/oauth-user-is-logged-in-but-unable-to-get-token/m-p/1575274#M86376</link>
    <description>&lt;P&gt;I have set up my javascript application with the client ID I generated in my esri online account.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;const &lt;/SPAN&gt;&lt;SPAN&gt;esriConfig &lt;/SPAN&gt;= {&lt;BR /&gt;    &lt;SPAN&gt;apiKey&lt;/SPAN&gt;: &lt;SPAN&gt;esriMapApiKey&lt;BR /&gt;&lt;/SPAN&gt;};&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var &lt;/SPAN&gt;&lt;SPAN&gt;oAuthInfo &lt;/SPAN&gt;= &lt;SPAN&gt;new &lt;/SPAN&gt;OAuthInfo({&lt;BR /&gt;    &lt;SPAN&gt;appId&lt;/SPAN&gt;: &lt;SPAN&gt;auth-client-id&lt;/SPAN&gt;,&lt;BR /&gt;    &lt;SPAN&gt;popup&lt;/SPAN&gt;: &lt;SPAN&gt;false&lt;/SPAN&gt;,&lt;BR /&gt;});&lt;BR /&gt;esriId.registerOAuthInfos([&lt;SPAN&gt;oAuthInfo&lt;/SPAN&gt;]);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I am able to login and it returns me to the same page. I am able to do a portal.queryItems.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The issue is that when I add a secure layer to the map, it throws an error saying it is unable to generate a token for the layer. It seems in my network tab, it calls out to&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;A href="https://www.arcgis.com/sharing/rest/generateToken" target="_blank" rel="noopener"&gt;https://www.arcgis.com/sharing/rest/generateToken&lt;/A&gt;&amp;nbsp;after the layer is added. That call returns an error saying&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;Unable to generate token for this server&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Is there something I need to change so that some calls happen before others. Do I need to make a manual POST call to get a token and append it to the URL for the feature service?&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Tue, 14 Jan 2025 13:33:11 GMT</pubDate>
    <dc:creator>ChaosSteve</dc:creator>
    <dc:date>2025-01-14T13:33:11Z</dc:date>
    <item>
      <title>Oauth user is logged in but unable to get token</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/oauth-user-is-logged-in-but-unable-to-get-token/m-p/1575274#M86376</link>
      <description>&lt;P&gt;I have set up my javascript application with the client ID I generated in my esri online account.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;SPAN&gt;const &lt;/SPAN&gt;&lt;SPAN&gt;esriConfig &lt;/SPAN&gt;= {&lt;BR /&gt;    &lt;SPAN&gt;apiKey&lt;/SPAN&gt;: &lt;SPAN&gt;esriMapApiKey&lt;BR /&gt;&lt;/SPAN&gt;};&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;var &lt;/SPAN&gt;&lt;SPAN&gt;oAuthInfo &lt;/SPAN&gt;= &lt;SPAN&gt;new &lt;/SPAN&gt;OAuthInfo({&lt;BR /&gt;    &lt;SPAN&gt;appId&lt;/SPAN&gt;: &lt;SPAN&gt;auth-client-id&lt;/SPAN&gt;,&lt;BR /&gt;    &lt;SPAN&gt;popup&lt;/SPAN&gt;: &lt;SPAN&gt;false&lt;/SPAN&gt;,&lt;BR /&gt;});&lt;BR /&gt;esriId.registerOAuthInfos([&lt;SPAN&gt;oAuthInfo&lt;/SPAN&gt;]);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;I am able to login and it returns me to the same page. I am able to do a portal.queryItems.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The issue is that when I add a secure layer to the map, it throws an error saying it is unable to generate a token for the layer. It seems in my network tab, it calls out to&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;A href="https://www.arcgis.com/sharing/rest/generateToken" target="_blank" rel="noopener"&gt;https://www.arcgis.com/sharing/rest/generateToken&lt;/A&gt;&amp;nbsp;after the layer is added. That call returns an error saying&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;Unable to generate token for this server&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;Is there something I need to change so that some calls happen before others. Do I need to make a manual POST call to get a token and append it to the URL for the feature service?&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Jan 2025 13:33:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/oauth-user-is-logged-in-but-unable-to-get-token/m-p/1575274#M86376</guid>
      <dc:creator>ChaosSteve</dc:creator>
      <dc:date>2025-01-14T13:33:11Z</dc:date>
    </item>
  </channel>
</rss>

