Access Private Map without login

716
1
07-03-2018 10:44 PM
GuilhermePigosso
New Contributor II

Hello all,

I'm not sure if it's possible, but we would like to access a private map without login. I'm trying to do that using the API token, but is not working very well. My code is something like:

require([
    "esri/views/MapView",
    "esri/WebMap",
    "esri/config",
    "esri/identity/IdentityManager",
    "dojo/domReady!"
], function(MapView, WebMap, esriConfig, esriId, domReady){

    esriConfig.portalUrl = "https://test.maps.arcgis.com/"

    var userToken = //get token from https://www.arcgis.com/sharing/rest/oauth2/token
    var token = {
        'server': 'https://test.maps.arcgis.com/rest/services',
        'token': userToken
    };
    esriId.registerToken(token);

    var webmap = new WebMap({
        portalItem: {
            id: "95e0b154327f45858e963f2974a51a6e"
        }
    });

    var view = new MapView({
        map: webmap,        
        container: "viewDiv"
    });
});

But is not working. The map area still blank, like if my map doesn't exists.

Any idea?

Thank you!

Tags (3)
0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus

Guilherme,

   I am not sure how to do it that way. I don't think you can get a token that lastest very long (I think 2 week at the most) for AGOL. The way I normally do this is by using the esri resources proxy.

https://community.esri.com/groups/technical-support/blog/2015/04/07/setting-up-a-proxy 

0 Kudos