Destroy Credentials not working

652
2
04-25-2022 04:42 AM
utility9213
New Contributor III

Good day everyone.

I am currently having troubles removing a user access token on my project. Everything runs well except I can't delete or remove the token when signing out of the account in my project. I have currently tried using the Identity Manager destoryCredentials() method as well as the revokeToken().

However, this does not work. Is there any input or something that I am missing out? 

  signOut: function () {
            var client = new AppClient();
            self.appClient = client;

            var ctx = window.AppContext,
                oauth;
            if (ctx.geoportal) oauth = ctx.geoportal.arcgisOAuth; //Get OAuth Data

            var portalUrl = oauth.portalUrl;
            arcgisUtils.arcgisUrl = portalUrl;  // PortalImplementation
            esriId._arcgisUrl = portalUrl;
this.removeCookie('esri_auth', "/"); var itemName = "esriJSAPIOAuth"; window.sessionStorage.removeItem(itemName); window.sessionStorage.removeItem("userRole"); window.sessionStorage.removeItem("userOrganisation"); window.sessionStorage.removeItem("userObjectId"); window.sessionStorage.removeItem("contactOrganisation"); window.sessionStorage.removeItem("distributionOrganisation"); window.sessionStorage.removeItem("fileId");
esriId.destroyCredentials(); AppClient.revokeToken(); window.location.reload();

}

 

 

 

0 Kudos
2 Replies
ReneRubalcava
Frequent Contributor

You should only need to use 

esriId.destroyCredentials()

Don't try to manually remove cookies or session storage, that could be causing an issue when the IdentityManager tries to clean up.

This app is a little older, but does this

https://github.com/Esri/nearby-javascript

Do you have a sample app showing this behavior? ArcGIS JSAPI version? Browser version? OS?

0 Kudos
utility9213
New Contributor III

Thanks for the reply, I tried removing the codes for the cookies and session storage. However, this does not do work as well. Sorry but there isn't a sample app for this project as it's a pretty large project. And by default the credentials are stored in the "esriJSAPIOAuth" session storage correct? Is there any other way to check where the credentials are stored? 

Currently the project is running on ArcGIS JSAPI 4.16, Google Chrome Version 100.0.4896.127, OS Windows 10 Pro Version 21H2.

Do let me know if there is anymore information/code needed thank you 🙂


0 Kudos