Can't use WebScene from portal

947
5
05-28-2021 11:23 AM
BrentGrossman
New Contributor III

I'm using the code below to try to show a WebScene. When I run it, though, I get a 403 error. In the network console, the request URL is shown as https://<myHostName.myDomain>/portal/sharing/rest/content/items/<webSceneID>. If I go to that URL in my browser, I also get a 403 error, though if I append my token (the same one used in the code) using ?token=<my token> at the end of that URL, I get an informational page about the Web Scene in our portal.

Do I need to do something else in my code to give me access to the WebScene in our portal, or does something need to be differently configured on the portal or the server hosting it? Note that I can use my token to add feature layers we have in our portal to a new WebScene created with a basemap, instead of a portalItem, and that works fine.

 

 

IdentityManager.registerToken(TOKEN);
esriConfig.portalUrl = "https://<myHostName.myDomain>/portal";
const scene = new WebScene({
    portalItem: {
        id: "<the ID of the WebScene in the portal>"
    }
});

const view = new SceneView({
    container: "viewDiv",
    map: scene,
    center: [-121.60681, 39.7592],
    zoom: 12
});

 

 

 

0 Kudos
5 Replies
BenElan
Esri Contributor

I would try adding the server URL parameter for registering a token. It is weird that it works when just adding a feature layer though. Is your Enterprise federated?

 

identityManager.registerToken({
    token: TOKEN,
    server: 'https://<myHostName.myDomain>/portal/sharing/rest'
})

 

 

 

 

0 Kudos
BrentGrossman
New Contributor III

Thanks, Ben. I tried what you suggested, but got the same result. I tried with and without 'expires' and 'ssl', since the documentation says these are optional.

0 Kudos
BenElan
Esri Contributor

How are you generating the token? Can you try generating the token directly in the app to see if that makes a difference. It is possible that there is an issue with the referrer. Here is some sample code:

https://codepen.io/benesri/pen/ExxwqMB

0 Kudos
BrentGrossman
New Contributor III

Thanks for the sample code (by the way, I assume the ...token on line 65 isn't supposed to be there). I'm still seeing the same response.

I did test with a different portal of ours, and was successful (not generating the token in the code, just with the token from the generateToken service for that portal). I know that we have a certificate problem with the first portal (it's preventing us from getting a token for this portal from code on the server side of our app), so I strongly suspect that's what's causing the problem now, though, as I mentioned in my original post, we are able to access feature layers using a token from the online service (.../portal/sharing/rest/generateToken).

0 Kudos
BenElan
Esri Contributor

Line 65 is correct in the sample, it is a destructuring assignment. However, it doesn't sound like a code issue since it worked with a different Portal. I suggest fixing the certificate issue and making sure the two Portals are configured in the same way.