Accessing webmap from enterprise in ArcGIS API for Java Script

437
2
03-01-2021 02:15 PM
himalaya_GIS
New Contributor

Hi,

I am trying to access the web map (Shared to the organisation) published in the enterprise portal using the ArcGIS API for javascript.

We have used SAML to access the portal (below settings)

himalaya_GIS_0-1614636544332.png

Code I am using

himalaya_GIS_1-1614636648222.png

Getting the below login screen - tried with my organisation login credentials, it says incorrect username and password? I was expecting to see my portal login screen instead of this? Any help will be appreciated.

himalaya_GIS_2-1614636719884.png

 

 

 

0 Kudos
2 Replies
KenBuja
MVP Honored Contributor

When I have to add in a service that requires signing in with my organization creditentials, I have to use OAuthInfo as well as IdentityManager, like this

 

    require([...,
      "esri/identity/OAuthInfo",
      "esri/identity/IdentityManager",
      ...
    ], function (..., OAuthInfo, identityManager, ...) {

      const portalUrl = 'your portal url';
      const info = new OAuthInfo({
        appId: "xxxxxxxxxxxxxxxx", //*** Your Client ID value goes here ***//
        popup: false // inline redirects don't require any additional app configuration
      });
      identityManager.registerOAuthInfos([info]);
      // send users to arcgis.com to login
      identityManager.getCredential(portalUrl);
      identityManager.checkSignInStatus(portalUrl).then(function () {
        layer = new FeatureLayer({
          portalItem: {
            id: "your item"
          },
          outFields: ["*"]
        });
      .
      .
      .
      });

 

MatthewDriscoll
MVP Regular Contributor

To add on to KenBuja answer we have found that when we publish things, portal will automatically assign tokens.  Check if any of layers, mapping application, etc. used in the map are using tokens in the data source.  I cannot find my notes on it, if I remember correctly we took out the token portion of the url, or changed the token portion of the URL to manager.

 

portal.jpg