<?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: ESRI JS API: IdentityManager: Store the oauth state in local-storage ? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/505662#M46978</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So as I've learned from the ESRI support this is not possible to do the enterprise logins. So time for hacking again....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone is interested, I've ended up copying the session storage entry that IdentityManager genarates into the local storage after each login. This handles also agol/any portal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's not the neatest piece of code but serves the purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #7a7a43;"&gt;changeOAuthStorage&lt;/SPAN&gt;() {
  &lt;SPAN style="color: #808080;"&gt;// REMOVE ANY ESRIJSAPIOAUTH entries in the session or local storages
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;key &lt;/SPAN&gt;= &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'esriJSAPIOAuth'&lt;/SPAN&gt;;
  &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window &lt;/SPAN&gt;&amp;amp;&amp;amp; &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;sessionStorage&lt;/SPAN&gt;) {
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;oauth &lt;/SPAN&gt;= &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;sessionStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;getItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;);
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(!&lt;SPAN style="color: #458383;"&gt;oauth&lt;/SPAN&gt;) {
      &lt;SPAN style="color: #000080; font-weight: bold;"&gt;return&lt;/SPAN&gt;;
    }
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;oauthObj &lt;/SPAN&gt;= &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;JSON&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;parse&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;oauth&lt;/SPAN&gt;);
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;localStorage&lt;/SPAN&gt;) {
      &lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;localStorageoAuths &lt;/SPAN&gt;=  &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;localStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;getItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;);
      &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(!&lt;SPAN style="color: #458383;"&gt;localStorageoAuths&lt;/SPAN&gt;) {
        &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;localStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;setItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;, &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;JSON&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;stringify&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;oauthObj&lt;/SPAN&gt;));
        &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;sessionStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;removeItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;);
        &lt;SPAN style="color: #000080; font-weight: bold;"&gt;return&lt;/SPAN&gt;;
      }
      &lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;lsAuth &lt;/SPAN&gt;= &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;JSON&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;parse&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;localStorageoAuths&lt;/SPAN&gt;);
      &lt;SPAN style="color: #458383;"&gt;lsAuth&lt;/SPAN&gt;[&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'/'&lt;/SPAN&gt;] = {...&lt;SPAN style="color: #458383;"&gt;lsAuth&lt;/SPAN&gt;[&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'/'&lt;/SPAN&gt;], ...&lt;SPAN style="color: #458383;"&gt;oauthObj&lt;/SPAN&gt;[&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'/'&lt;/SPAN&gt;]};
      &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;localStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;setItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;, &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;JSON&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;stringify&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;lsAuth&lt;/SPAN&gt;));
      &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;sessionStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;removeItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;);
    }
  }
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also noticed that IdentityManager 3.x has different inner workings to 4.x as it's not storing any serialized state into session nor the local storage. Has the capability of restoring the state even if accessing the internal portal externally via azure application proxy. 4.x cannot handle it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 22:11:13 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-11T22:11:13Z</dc:date>
    <item>
      <title>ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/505661#M46977</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I've asked a similar question before, and also resolved it myself here:&lt;BR /&gt;&lt;A href="https://community.esri.com/thread/233747"&gt;ESRI JS API: IdentityManager: how to use localStorage&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This was for the scenario, where I've used the&amp;nbsp;&lt;STRONG&gt;popup: true&lt;/STRONG&gt; for the OAuth2.0 authentication.&lt;BR /&gt;&lt;BR /&gt;However, I'm now in the scenario where I have to use&amp;nbsp;&lt;STRONG&gt;redirect&amp;nbsp;&lt;/STRONG&gt;to the agol's/portal's&lt;STRONG&gt; oAuth page&lt;/STRONG&gt; insteas of a popup, so I have to use the&amp;nbsp;&lt;STRONG&gt;popup: false.&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;This seem to work fine, but the problem is that user has to approve the access each time he opens the app, because the oath state is stored in&amp;nbsp;&lt;STRONG&gt;session-storage&lt;/STRONG&gt; in&amp;nbsp;&lt;STRONG&gt;esriJSAPIOauth&lt;/STRONG&gt; property, instead of&amp;nbsp;&lt;STRONG&gt;local-storage.&lt;/STRONG&gt;&amp;nbsp;I guess this all happens as there is no presence of any 'Keep Me Signed In' or similar checkbox for the enterprise login oAuth page.&lt;BR /&gt;&lt;BR /&gt;Does anyone know how can I force the IdentityManager to store the redirected oauth state into the session-storage ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ESRI JS API: 4.14&lt;BR /&gt;AGOL/PORTAL SECURITY: Enterprise logins&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Mar 2020 23:48:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/505661#M46977</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-03-04T23:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/505662#M46978</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So as I've learned from the ESRI support this is not possible to do the enterprise logins. So time for hacking again....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone is interested, I've ended up copying the session storage entry that IdentityManager genarates into the local storage after each login. This handles also agol/any portal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's not the neatest piece of code but serves the purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #7a7a43;"&gt;changeOAuthStorage&lt;/SPAN&gt;() {
  &lt;SPAN style="color: #808080;"&gt;// REMOVE ANY ESRIJSAPIOAUTH entries in the session or local storages
&lt;/SPAN&gt;&lt;SPAN style="color: #808080;"&gt;  &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;key &lt;/SPAN&gt;= &lt;SPAN style="color: #008000; font-weight: bold;"&gt;'esriJSAPIOAuth'&lt;/SPAN&gt;;
  &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window &lt;/SPAN&gt;&amp;amp;&amp;amp; &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;sessionStorage&lt;/SPAN&gt;) {
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;oauth &lt;/SPAN&gt;= &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;sessionStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;getItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;);
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(!&lt;SPAN style="color: #458383;"&gt;oauth&lt;/SPAN&gt;) {
      &lt;SPAN style="color: #000080; font-weight: bold;"&gt;return&lt;/SPAN&gt;;
    }
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;oauthObj &lt;/SPAN&gt;= &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;JSON&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;parse&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;oauth&lt;/SPAN&gt;);
    &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;localStorage&lt;/SPAN&gt;) {
      &lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;localStorageoAuths &lt;/SPAN&gt;=  &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;localStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;getItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;);
      &lt;SPAN style="color: #000080; font-weight: bold;"&gt;if &lt;/SPAN&gt;(!&lt;SPAN style="color: #458383;"&gt;localStorageoAuths&lt;/SPAN&gt;) {
        &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;localStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;setItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;, &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;JSON&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;stringify&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;oauthObj&lt;/SPAN&gt;));
        &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;sessionStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;removeItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;);
        &lt;SPAN style="color: #000080; font-weight: bold;"&gt;return&lt;/SPAN&gt;;
      }
      &lt;SPAN style="color: #000080; font-weight: bold;"&gt;const &lt;/SPAN&gt;&lt;SPAN style="color: #458383;"&gt;lsAuth &lt;/SPAN&gt;= &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;JSON&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;parse&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;localStorageoAuths&lt;/SPAN&gt;);
      &lt;SPAN style="color: #458383;"&gt;lsAuth&lt;/SPAN&gt;[&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'/'&lt;/SPAN&gt;] = {...&lt;SPAN style="color: #458383;"&gt;lsAuth&lt;/SPAN&gt;[&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'/'&lt;/SPAN&gt;], ...&lt;SPAN style="color: #458383;"&gt;oauthObj&lt;/SPAN&gt;[&lt;SPAN style="color: #008000; font-weight: bold;"&gt;'/'&lt;/SPAN&gt;]};
      &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;localStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;setItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;, &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;JSON&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;stringify&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;lsAuth&lt;/SPAN&gt;));
      &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;window&lt;/SPAN&gt;.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;sessionStorage&lt;/SPAN&gt;.&lt;SPAN style="color: #7a7a43;"&gt;removeItem&lt;/SPAN&gt;(&lt;SPAN style="color: #458383;"&gt;key&lt;/SPAN&gt;);
    }
  }
}&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've also noticed that IdentityManager 3.x has different inner workings to 4.x as it's not storing any serialized state into session nor the local storage. Has the capability of restoring the state even if accessing the internal portal externally via azure application proxy. 4.x cannot handle it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:11:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/505662#M46978</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T22:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1005396#M70934</link>
      <description>&lt;P&gt;Wow..! Very impressive..!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":clapping_hands:"&gt;👏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 29 Nov 2020 17:21:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1005396#M70934</guid>
      <dc:creator>Ranga_Tolapi</dc:creator>
      <dc:date>2020-11-29T17:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1044549#M72387</link>
      <description>&lt;P&gt;I only have one word for this. Awesome.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Apr 2021 09:52:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1044549#M72387</guid>
      <dc:creator>RichardK</dc:creator>
      <dc:date>2021-04-07T09:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1087799#M74244</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous User&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Greetings!&lt;/P&gt;&lt;P&gt;I hope you are doing well. I must have to say this solution is great and, I have a question, can we implement this for ArcGIS Online (if yes, then where can we put this code). I am asking this because I am implementing this with ArcGIS web app builder custom application and AGOL in the backend.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any assistance you can provide would be greatly appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Harsh&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 03:41:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1087799#M74244</guid>
      <dc:creator>HarshvardhanSwami-Provista</dc:creator>
      <dc:date>2021-08-11T03:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1087804#M74246</link>
      <description>&lt;P&gt;Hi Harsh, well that I don't know. never worked with the webapp builder so not sure to what extent you can control the oauth process, tbh I don't think it's possible as the core of the application that runs your web application builder code handles all the oauth communication. Sorry&lt;/P&gt;</description>
      <pubDate>Wed, 11 Aug 2021 05:22:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1087804#M74246</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-08-11T05:22:56Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1117832#M75321</link>
      <description>&lt;P&gt;Michal, I am looking to implement this in a pure ArcGIS JS page but I am unsure where this is supposed to go. I receive an error message that reads&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;Uncaught SyntaxError: Unexpected token '{'&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Should this be part of a function?&lt;/P&gt;&lt;P&gt;What I am trying to do is, I have a link in the feature popup within my web app that opens up an external page that shows just the desired feature and the attributes, what I'd like is for the log in information to persist to that page so users do not have to log in again or click allow for "Request for Permission" everytime they click on a link.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 19:15:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1117832#M75321</guid>
      <dc:creator>luckachi</dc:creator>
      <dc:date>2021-11-17T19:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1117863#M75326</link>
      <description>Hi, that's bit unusual to login and query for data on one page, and then&lt;BR /&gt;from popup open new page where you query rest service again.&lt;BR /&gt;&lt;BR /&gt;If you already have the token, just pass it in the queryparams to a new&lt;BR /&gt;page and use it for your queries on the new page..&lt;BR /&gt;&lt;BR /&gt;You are not providing enough details about the error, but perhaps you are&lt;BR /&gt;not formatting the response as JSON or the JSON has an invalid structure?&lt;BR /&gt;Hard to say&lt;BR /&gt;</description>
      <pubDate>Wed, 17 Nov 2021 19:49:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1117863#M75326</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-11-17T19:49:43Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1117871#M75327</link>
      <description>&lt;P&gt;Sorry I was not very clear. I have a web mapping application (not JS, AGO)&amp;nbsp; that is not public due to the nature of the information collected. The link within the popup opens a page that sits within our website structure that only displays the selected feature (the feature in which you viewed the popup for and clicked the link) and the attributes. This is so users can print it for annual reporting.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;That must be, I was not aware this involved JSON. Right now I just have this, which worked to get rid of the full log in and just requires you to click Allow but I would like this page to know whether or not the user is already logged in to AGO and not ask anything prior to the page loading.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var appURL = "our URL",
  appURLSharing = appURL + "/sharing";


let info = new OAuthInfo({
   appId: "our app ID",
   popup: false,
   preserveUrlHash: true
 });

esriId.registerOAuthInfos([info]);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Nov 2021 19:59:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1117871#M75327</guid>
      <dc:creator>luckachi</dc:creator>
      <dc:date>2021-11-17T19:59:54Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1566862#M86221</link>
      <description>&lt;P&gt;EDIT: The original method ended up not working in some cases. If the user refreshed the page at any point, it would log them out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As it turns out, there is a supported but not well-documented way to do this in the API using the IdentityManager's &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#toJSON" target="_self"&gt;toJSON()&lt;/A&gt; and&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#initialize" target="_self"&gt;initialize()&lt;/A&gt;&amp;nbsp;methods. My approach (which appears to work just fine) is this:&lt;/P&gt;&lt;P&gt;1. Any time the IdentityManager object might be updated (e.g. when a user logs in or out), store its state in localStorage:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import esriId from '@arcgis/core/identity/IdentityManager'

const jsonId = esriId.toJSON();
window.localStorage.setItem(
    'my-app:identity-manager', 
    JSON.stringify(jsonID)
);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Whenever your application loads/initializes, grab the IdentityManager state from localStorage:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const jsonId = JSON.parse(
    window.localStorage.getItem('my-app:identity-manager')
);
if (jsonId) {
    esriId.initialize(jsonId);
}&lt;/LI-CODE&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;ORIGINAL REPLY:&lt;/P&gt;&lt;P&gt;This was a lifesaver, even a few years down the road. Thanks! Here's my implementation. I just streamlined things a bit and took out the part where we delete the sessionStorage entry (that was causing issues for me).&lt;/P&gt;&lt;P&gt;[EDIT WARNING: Read note at the top of this reply. This method does not work.]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;changeOAuthStorage() {
    if (!window?.sessionStorage || !window?.localStorage) return;

    const key = 'esriJSAPIOAuth';

    const sessionOAuthString = window.sessionStorage.getItem(key);
    if (!sessionOAuthString) return;

    const localOAuthString = window.localStorage.getItem(key);
    if (!localOAuthString) {
      window.localStorage.setItem(key, sessionOAuthString);
    } else {
      const sessionOAuthObj = JSON.parse(sessionOAuthString);
      const localOAuthObj = JSON.parse(localOAuthString);

      // copy the new session obj over the localstorage entry but keep any
      // properties that aren't in the new session obj
      localOAuthObj['/'] = { ...localOAuthObj['/'], ...sessionOAuthObj['/']};
      window.localStorage.setItem(key, JSON.stringify(localOAuthObj));
    }
  };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Dec 2024 18:18:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1566862#M86221</guid>
      <dc:creator>fdeters</dc:creator>
      <dc:date>2024-12-16T18:18:55Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1620467#M87222</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/710429"&gt;@fdeters&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;This solution seems like exactly what I need. Could you please explain where I should implement this code? I want to apply this solution to my web app which is built using ArcGIS Experience Builder Developer Edition.&lt;BR /&gt;Cheers,&lt;BR /&gt;Luc&lt;/P&gt;</description>
      <pubDate>Tue, 03 Jun 2025 14:53:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1620467#M87222</guid>
      <dc:creator>LucVanDijk</dc:creator>
      <dc:date>2025-06-03T14:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: ESRI JS API: IdentityManager: Store the oauth state in local-storage ?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1621013#M87226</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/784755"&gt;@LucVanDijk&lt;/a&gt;! Unfortunately, I am not familiar with Experience Builder Developer Edition. My recommendation is to search the &lt;A href="https://developers.arcgis.com/experience-builder/api-reference" target="_self"&gt;Experience Builder Developer Edition documentation&lt;/A&gt;&amp;nbsp;(the &lt;A href="https://developers.arcgis.com/experience-builder/api-reference/jimu-core/State/" target="_self"&gt;documentation page for jimu/core/State&lt;/A&gt;&amp;nbsp;might be a good place to start).&lt;/P&gt;&lt;P&gt;Ultimately, you want to make sure that:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Whenever the user's login status changes, the IdentityManager is saved in LocalStorage.&lt;/LI&gt;&lt;LI&gt;The app looks for IdentityManager data stored in LocalStorage&amp;nbsp;&lt;EM&gt;before&lt;/EM&gt; redirecting the user to the login flow.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Because of my lack of Experience Builder Developer Edition knowledge, I'm not sure either of those things are possible. Good luck! I'd be interested to know if you find a solution.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 21:47:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/esri-js-api-identitymanager-store-the-oauth-state/m-p/1621013#M87226</guid>
      <dc:creator>fdeters</dc:creator>
      <dc:date>2025-06-04T21:47:43Z</dc:date>
    </item>
  </channel>
</rss>

