var serverInfo = new ServerInfo();
serverInfo.server = "https://wl.arcgisonline.cn/server/rest/services";
serverInfo.tokenServiceUrl = "https://wl.arcgisonline.cn/portal/sharing/rest/generateToken";
var userInfo = {username:"***",password:"***"};IdentityManager.generateToken(serverInfo,userInfo).then(function(data){
var tokenValue = data.token; IdentityManager.registerToken({server:"https://wl.arcgisonline.cn/server/rest/services",token:tokenValue});
},function(error){
console.error(error);
});var layer = new MapImageLayer({url: "https://wl.arcgisonline.cn/server/rest/services/wl/time1/MapServer"});
map.add(layer);
The token used to access SceneLayer comes from IdentityManager.registerToken.
My question is, when accessing the SceneLayer data, must the url be consistent with the server in IdentityManager.registerToken? Can I use the following methods (must bring the token)
var layer = new MapImageLayer({url: "https://172.16.8.11:8080/server/rest/services/wl/time1/MapServer"});
Can the url of the layer be different from the server address in IdentityManager.registerToken? Token required
Solved! Go to Solution.
As far as I know, the short answer is no, since IdentityManager has no means of knowing when different host names refer to the same host. However, the workaround is otherwise simple. If you intend to use multiple host names that refer to the same host, you can simply call registerToken for each host name with the same token:
IdentityManager.registerToken({server:"https://server1/server/rest/services", token:tokenValue});
IdentityManager.registerToken({server:"https://server2/server/rest/services", token:tokenValue});
IdentityManager.registerToken({server:"https://192.168.1.2/server/rest/services", token:tokenValue});
As far as I know, the short answer is no, since IdentityManager has no means of knowing when different host names refer to the same host. However, the workaround is otherwise simple. If you intend to use multiple host names that refer to the same host, you can simply call registerToken for each host name with the same token:
IdentityManager.registerToken({server:"https://server1/server/rest/services", token:tokenValue});
IdentityManager.registerToken({server:"https://server2/server/rest/services", token:tokenValue});
IdentityManager.registerToken({server:"https://192.168.1.2/server/rest/services", token:tokenValue});
that seems to be the only way, thank you