Select to view content in your preferred language

Can the url of the layer be different from the server address in IdentityManager.registerToken? Token required

709
2
Jump to solution
01-09-2023 04:39 AM
rendtime
Emerging Contributor

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

 

0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

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});

 

View solution in original post

0 Kudos
2 Replies
JoelBennett
MVP Regular Contributor

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});

 

0 Kudos
rendtime
Emerging Contributor

that seems to be the only way, thank you

0 Kudos