ESRI JS API: IdentityManager: how to use localStorage

669
2
05-13-2019 05:59 PM
MichalGasparovic1
New Contributor III

Hi there,

I've followed few sample on OAuth and IdentityManager and successfully implemented it into our internal portal, but each time a user closes the window, he has to authenticate himself again when accessing the application. After inspecting the browser storage data, I've noticed the OAuth info is stored in he sessionStorage rather than localStorage

Once user is authenticated and redirected from ESRI Login Page, I'm using the following function to finalize the login.

if (window.location.hash) {
window.opener.require('esri/kernel').id.setOAuthResponseHash(window.location.hash)
window.close()
}

But how can I tell the IdentityManager to use the localStorage instead of sessionStorage?

Thank you.

0 Kudos
2 Replies
MichalGasparovic1
New Contributor III

ok, so by reverse engineering the js api for IdentityManager, I've added the 

&persist=true

to the response hash.

if (window.location.hash) {
  window.opener.require('esri/kernel').id.setOAuthResponseHash(window.location.hash + '&persist=true')
  window.close()
}

And that has forced the IdentityManager to store it in the localStorage rather than the sessionStorage.

Interesting thing is, that the ESRI's login popup window doesn't have 'Remember Me' checkbox for enterprise logins, but it does for the standard login. I believe this would've solved our issue but at least I have the workaround.

Ranga_Tolapi
Occasional Contributor II

Excellent!!!

0 Kudos