0

I am migrating a 3.x Enterprise ArcGIS Server Javascript application to 4.x. The application adds secured FeatureLayer layers to the map using a service token that was generated by a separate process.

In the 3.x application, this token was simply passed in the "token" query string parameter, like this:

new esri.layers.FeatureLayer("https://blahblah/MapServer/1?token=abc123");

However, in 4.x (JavaScript SDK), this is deprecated and it seems they want the token to be passed inside an "X-Esri-Authentication" Bearer token (HTTP header), as described in the documentation here:

https://enterprise.arcgis.com/en/server/latest/administer/windows/about-arcgis-tokens.htm

The issue I'm having is that I don't see a way to actually add that header. All the documentation talks about using EsriRequest, which is not what I'm doing here.

I tried to use the IdentityManager like this:

IdentityManager.registerToken({
  server: "https://example.com/bar/rest/services",
  token: "<the generated token string here>"
});

...and this doesn't throw any errors, but it doesn't do anything else, either. To be sure, I captured the traffic with Fiddler and searched for the token and the token wasn't found anywhere for the above code snippet.

I've found a few community posts from people asking this same question, as well as some older questions here on StackOverflow (but those are old enough where people just suggest adding the "token" to the query string). The documentation simply doesn't cover this very well, so has anyone done this specific setup yet?

1 Answer 1

0

So it turns out the IdentityManager.registerToken() approach DID work but the client application was using a couple of different subdomains. So I was trying:

server: "https://foo.example.com/arcgis/rest/services"

...but the the FeatureLayer was on bar.example.com, so the server parameter needed to be:

server: "https://bar.example.com/arcgis/rest/services"

Because of the mismatch, when I added the FeatureLayer, the IdentityManager couldn't find a token that was valid for that domain.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.