Select to view content in your preferred language

ESRI JS API: IdentityManager: how to use localStorage

2080
3
05-13-2019 05:59 PM
by Anonymous User
Not applicable

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
3 Replies
by Anonymous User
Not applicable

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
Frequent Contributor

Excellent!!!

0 Kudos
MrGIS
by
Emerging Contributor

Where do you put this code at. I want to use it for my node.js app

0 Kudos