Basemap Gallery Requiring Login on Public Web Map

1607
8
11-27-2018 04:55 AM
JamesS1
Occasional Contributor

I have a web map in a JavaScript API application that is public and loads fine. The Basemap Gallery widget, however, is requiring a login when I set the default portal in esriConfig.portalUrl. The login prompt is showing the id as 5b4ad9cb601c45e8978901b08dc087b8, but I can't find that item anywhere. Is there a setting somewhere or some other action that needs to be performed to allow the ArcGIS basemaps to load without logging in?

0 Kudos
8 Replies
Noah-Sager
Esri Regular Contributor

Hi James. I did some testing with a webmap and the Basemap Gallery widget using my own portal in the esriConfig.portalUrl and version 4.9 of the ArcGIS API for JavaScript, and it seems to work fine.

What version of the API are you using? Which browser? Could you share a code sample that reproduces the issue?

0 Kudos
JamesS1
Occasional Contributor

The API version is 4.9 and the issue occurs in all browsers. There are two scenarios - entering as a guest and logging in (with Portal). When logging in with Portal (which redirects to the Portal login and returns back to the application), everything is fine. When entering a guest, the only thing set is esriConfig - portalUrl and trustedServers.

What is unclear is why using a public web map in a Portal instance would require a login for the basemap gallery where all the basemaps are public... and where the item (5b4ad9cb601c45e8978901b08dc087b8) comes from.

I don't have a full sample, as these are Angular applications and imported libraries, but this is the code from one of the libraries to set the esriConfig and IdentityManager:

setConfigAndIdentityManager(portalUrl: string) {
esriLoader.loadModules([
'esri/config',
'esri/identity/IdentityManager'
]).then(([
esriConfig,
esriId
]:[
__esri.config,
__esri.IdentityManager
]) => {
this.srvcEsriConfig = esriConfig;
this.srvcEsriConfig.portalUrl = portalUrl;
this.srvcEsriConfig.request.trustedServers.push(portalUrl);

this.srvcEsriId = esriId;
});
}
0 Kudos
Noah-Sager
Esri Regular Contributor

Ok, I don't know a ton about Angular or where the item (5b4ad9cb601c45e8978901b08dc087b8) comes from, but maybe we can simplify this workflow as a proof of concept. Can you try running this sample with your portalURL and webmap id, just to see if it works? This is what I understand of your workflow. Also, which version of Portal for ArcGIS are you running? This works for me with 10.6.1.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title>BasemapGallery + Webmap</title>
<link rel="stylesheet" href="https://js.arcgis.com/4.9/esri/css/main.css">
<style>
html,
body,
#viewDiv {
padding: 0;
margin: 0;
height: 100%;
width: 100%;
}
</style>
<script src="https://js.arcgis.com/4.9/"></script>
<script>
require([
"esri/Map",
"esri/views/SceneView",
"esri/widgets/BasemapGallery",
"esri/config",
"esri/WebMap"
], function(
Map, SceneView, BasemapGallery, esriConfig, WebMap
) {

var portalUrl = "";

// Set the hostname to the on-premise portal and trust it
esriConfig.portalUrl = portalUrl;
esriConfig.request.trustedServers.push(portalUrl);

var webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()
id: ""
}
});

var map = new Map({
basemap: "gray"
});

var view = new SceneView({
container: "viewDiv",
map: webmap,
center: [139.68, 35.68],
zoom: 3
});

var basemapGallery = new BasemapGallery({
view: view
});

// Add the widget to the top-right corner of the view
view.ui.add(basemapGallery, {
position: "top-right"
});
});
</script>
</head>
<body>
<div id="viewDiv"></div>
</body>
</html>

<!DOCTYPE HTML><html><head>  <meta charset="utf-8">  <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">  <title>BasemapGallery + Webmap</title>  <link rel="stylesheet" href="https://js.arcgis.com/4.9/esri/css/main.css">  <style>    html,     body,     #viewDiv {       padding: 0;       margin: 0;       height: 100%;       width: 100%;     }  </style>  <script src="https://js.arcgis.com/4.9/"></script>  <script>    require([       "esri/Map",       "esri/views/SceneView",       "esri/widgets/BasemapGallery",       "esri/config",       "esri/WebMap"    ], function(      Map, SceneView, BasemapGallery, esriConfig, WebMap     ) {              var portalUrl = "";              // Set the hostname to the on-premise portal and trust it      esriConfig.portalUrl = portalUrl;       esriConfig.request.trustedServers.push(portalUrl);              var webmap = new WebMap({         portalItem: { // autocasts as new PortalItem()          id: ""        }       });        var map = new Map({         basemap: "gray"      });        var view = new SceneView({         container: "viewDiv",         map: webmap,         center: [139.68, 35.68],         zoom: 3      });        var basemapGallery = new BasemapGallery({         view: view       });        // Add the widget to the top-right corner of the view      view.ui.add(basemapGallery, {         position: "top-right"      });     });   </script></head><body>  <div id="viewDiv"></div></body></html>
0 Kudos
JamesS1
Occasional Contributor

Noah,

I believe Portal is 10.6. I added the portal and web map:

var portalUrl = "https://gistestportal.vhb.com/site";

id: "f040dad144344feb8fc7afb832e9a9bc"

Still getting the login:

login required

0 Kudos
Noah-Sager
Esri Regular Contributor

Ok. Another thing that I don't know a ton about, but I think I narrowed it down a bit. I think the issue is related to the Basemap group content. I found where the 5b4ad9cb601c45e8978901b08dc087b8 comes from (this is what it looks like in my Portal instance):

This seems to be the group that holds the AGOL Basemaps, which is currently not public in your portal. E.g.: 

https://gistestportal.vhb.com/site/sharing/rest/content/groups/5b4ad9cb601c45e8978901b08dc087b8 

What does the Basemap Gallery setting look like in your Portal org? This is mine (default setting):

Perhaps what we need to do is update the sharing of the Basemap Gallery in your Portal.

0 Kudos
JamesS1
Occasional Contributor

Thanks for all the info. It seems to be an issue with the Esri JavaScript API widget and how it is set (portalbasemapssource, localbasemapssource). I probably need to get tech support on this as this is a public application that uses a publicly shared web map from ArcGIS Portal and even though everything is "public" it is requiring a login to access the basemaps...

0 Kudos
ez4gis
by Esri Contributor
Esri Contributor

Hi James,  just wondering is your issue resolved through tech support? ! We ran into same issue recently. The id on login windows is the id of basemap group.  thanks

0 Kudos
ez4gis
by Esri Contributor
Esri Contributor

In case anyone came here for similar issue,  we were able to resolve our issue by upgrading portal from 10.6 to 10.6.1.