Select to view content in your preferred language

Is there a way to test my implementation of user authentication in WAB Dev Edition?

679
1
10-12-2022 03:05 AM
ViktorSafar
Frequent Contributor

I have a widget in WAB Dev Edition which uses the `IdentityManager` to manage the user authentication.

The problem is that my WAB Dev Edition requires me to be logged in so the widget always receives an already logged in user. I also implemented a log out function via `IdentityManager.destroyCredentials()` but on page reload the WAB asks me to log in. So I never get to test my authentication code.

0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

I have a custom widget that uses IdentityManager. I have a button to let the user sign in which uses OAuthInfo with a popup. This is how I call it

const info = new ArcGISOAuthInfo({
  appId: theAppId,
  popupCallbackUrl: thePopupCallbackUrl,
  popup: true,
  portalUrl: this._portalUrl
});
esriId.registerOAuthInfos([info]); //this is the IdentityManager
esriId
  .getCredential(info.portalUrl, {
  oAuthPopupConfirmation: true
})
  .then( 
      lang.hitch(this, function () {
        this._portal = new arcgisPortal.Portal(this._portalUrl);
        this._portal
          .signIn()
          .then(
             // do everything using the Identity manager

The popup allows me to either use my existing account that I'm running WAB DE or to use another account.

2022-10-12_9-48-25.png

I have a button to sign out of the portal, but it uses Portal.signOut. I have to use this button when I launch my app from WAB DE since it automatically signs me in.

0 Kudos