[RESOLVED] How to destroy a single credential from many?

02-14-2020 01:47 PM
New Contributor III


I have a web application that requires user to switch between different portals (AGOL + 2x on-prem PORTALS). Each time the requested resource requires a portal access, I'm switching using the immediate authentication option. This all works ok. If not logged in I use OAuth2.0.

However, I wanted to add the option of sign-out of the portal, so I'm receiving the credential from identity manager and destroy it. However, I've noticed that that credentials still exist within the IdentityManager.credentials and also in the local storage under esriJSAPIOAuth .

However, if I use IdentityManager.destroyCredentials() it works, but that's not what I want.

const credential = this.identityManager.findCredential(url);
if (credential && asset !== 'agol') {
  console.log(`Authentication.service.ts: logout: LOGGING OUT user: ${credential.userId}. [${asset} (${url})]`);

Any ideas? OR do I have to do it manually ? 

Thank you

0 Kudos
1 Reply
New Contributor III

Seems like I've had a bug there (deeper in the code), but I'll keep testing and see if this works ok.

I do, however, have another thing to note. I initialize IdentityManager from JSON I've serialized before user closes the application. but with each new login, the credentials array keeps growing even for the same portal and user id. I'd have expected it to be cleaned up. But seems like I'll have to handle this myself