<?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: IdentityManager: keep user signed in after browser refresh in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identitymanager-keep-user-signed-in-after-browser/m-p/1012902#M71237</link>
    <description>&lt;P&gt;I had the same issue and I solved it like this &lt;A href="https://codepen.io/hhkaos/pen/VwKQjLJ?editors=1000" target="_self"&gt;https://codepen.io/hhkaos/pen/VwKQjLJ?editors=1000&lt;/A&gt; [codepen.io]&lt;/P&gt;&lt;P&gt;The different between the &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/identity-oauth-basic/index.html" target="_self"&gt;ArcGIS Online sample&lt;/A&gt; and ArcGIS Enterprise was that &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#portalUrl" target="_self"&gt;portalURL&lt;/A&gt; in the OAuthInfo class expects a different URL than the identityManager methods like &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#getCredential" target="_self"&gt;getCredential&lt;/A&gt; or &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#checkSignInStatus" target="_self"&gt;checkSignInStatus&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;So it would be something like this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;oAuthInfo.portalURL= "https://yourdomain/arcgis"&lt;/LI&gt;&lt;LI&gt;identityManager.getCredential("https://yourdomain/arcgis/sharing")&lt;/LI&gt;&lt;LI&gt;identityManager.checkSignInStatus("https://yourdomain/arcgis/sharing")&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I hope this helps to the next one having this issue.&lt;/P&gt;&lt;P&gt;Cheers!,&lt;BR /&gt;Raul&lt;/P&gt;</description>
    <pubDate>Wed, 30 Dec 2020 14:59:51 GMT</pubDate>
    <dc:creator>RaulJimenez1</dc:creator>
    <dc:date>2020-12-30T14:59:51Z</dc:date>
    <item>
      <title>IdentityManager: keep user signed in after browser refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identitymanager-keep-user-signed-in-after-browser/m-p/239097#M22210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have developed an application that shows a WebMap from ArcGIS portal by using the ArcGIS JS API. I implemented authentication flow by using the IdentityManager. I'm able to get the token and register it and the secured resource then loads correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when I refresh the page in browser the registered token/credential is not available anymore. Is there a way to keep the sign in status as long as the token is valid? Or is it so that I need to store the access token (and possibly other needed details) my self in client side and then just validate the token before request to JS API and register it again?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is the recommended way to do this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Eemeli&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;identityManager&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;checkSignInStatus&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; portalUrl &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"/sharing"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;then&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; credential &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;

			&lt;SPAN class="comment token"&gt;// User is already authenticated.&lt;/SPAN&gt;
			identityManager&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;registerToken&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
				token&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; credential&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;token&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
				server&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; portalUrl
			&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
			&lt;SPAN class="token function"&gt;resolve&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;true&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

		&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;catch&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; error &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;

			&lt;SPAN class="comment token"&gt;// User not authenticated, login the user.&lt;/SPAN&gt;
			identityManager&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;getCredential&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; portalUrl &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"/sharing"&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;then&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; credential &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;

				&lt;SPAN class="comment token"&gt;// Register the token after authentication.&lt;/SPAN&gt;
				&lt;SPAN class="comment token"&gt;// The token is valid 60 min by default.&lt;/SPAN&gt;
				identityManager&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;registerToken&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
					token&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; credential&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;token&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
					server&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; portalUrl &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"/sharing/rest"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
					expires&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; credential&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;expires&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
					ssl&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; credential&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ssl&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
					userId&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; credential&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;userId
				&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
				&lt;SPAN class="token function"&gt;resolve&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;true&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

			&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
		&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:02:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identitymanager-keep-user-signed-in-after-browser/m-p/239097#M22210</guid>
      <dc:creator>EemeliP</dc:creator>
      <dc:date>2021-12-11T12:02:22Z</dc:date>
    </item>
    <item>
      <title>Re: IdentityManager: keep user signed in after browser refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identitymanager-keep-user-signed-in-after-browser/m-p/239098#M22211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Late reply... but helpful if anyone else comes across this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My understanding is that if you don't use IdentityManager OAuth flow you're left to your own devices to store and re-register the token. Underneath your `&lt;SPAN&gt;IdentityManager.&lt;/SPAN&gt;registerToken` call, store the response in localStorage. Then on page load, grab the token out of localStorage, and register it again via `IdentityManager.registerToken`.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How to request a refresh token when a call returns 403 forbidden? That's another story I'm currently investigating. I'll report back if I figure it out.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 Aug 2020 04:39:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identitymanager-keep-user-signed-in-after-browser/m-p/239098#M22211</guid>
      <dc:creator>CoMAGOL_ADMINISTRATOR</dc:creator>
      <dc:date>2020-08-07T04:39:09Z</dc:date>
    </item>
    <item>
      <title>Re: IdentityManager: keep user signed in after browser refresh</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identitymanager-keep-user-signed-in-after-browser/m-p/1012902#M71237</link>
      <description>&lt;P&gt;I had the same issue and I solved it like this &lt;A href="https://codepen.io/hhkaos/pen/VwKQjLJ?editors=1000" target="_self"&gt;https://codepen.io/hhkaos/pen/VwKQjLJ?editors=1000&lt;/A&gt; [codepen.io]&lt;/P&gt;&lt;P&gt;The different between the &lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/identity-oauth-basic/index.html" target="_self"&gt;ArcGIS Online sample&lt;/A&gt; and ArcGIS Enterprise was that &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-OAuthInfo.html#portalUrl" target="_self"&gt;portalURL&lt;/A&gt; in the OAuthInfo class expects a different URL than the identityManager methods like &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#getCredential" target="_self"&gt;getCredential&lt;/A&gt; or &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-identity-IdentityManager.html#checkSignInStatus" target="_self"&gt;checkSignInStatus&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;So it would be something like this:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;oAuthInfo.portalURL= "https://yourdomain/arcgis"&lt;/LI&gt;&lt;LI&gt;identityManager.getCredential("https://yourdomain/arcgis/sharing")&lt;/LI&gt;&lt;LI&gt;identityManager.checkSignInStatus("https://yourdomain/arcgis/sharing")&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I hope this helps to the next one having this issue.&lt;/P&gt;&lt;P&gt;Cheers!,&lt;BR /&gt;Raul&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 14:59:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/identitymanager-keep-user-signed-in-after-browser/m-p/1012902#M71237</guid>
      <dc:creator>RaulJimenez1</dc:creator>
      <dc:date>2020-12-30T14:59:51Z</dc:date>
    </item>
  </channel>
</rss>

