Want to access secure services using tokens - sample code?

340
1
09-08-2022 11:34 PM
MichaelBell
New Contributor III

I'm using an ArcGIS Enterprise install, meaning we have our own server with "server" and "portal" webadaptors on one of our machines, which will serve our data.

Our users go onto this and can sign on using a single sign on with Azure AD. They've been using this, along with an OAuth2 app, to sign in securely and view our data, and we've got various controls set up using ESRI JS.

Unfortunately, a change in software has meant we cannot use the OAuth2 app any more, and the only way I can see of doing what we need is to use tokens. I've tried to make sense of this, but I'm struggling to find many good samples of what I want.

I've gone into our Server Manager and copied out the Shared Key, but now I don't know what to do.

0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

You could use FeatureLayer.customParameters property to set the token for the given service. The customParameters get appended to all network requests associated with the service. Hope this makes sense. 

 

let layer = new MapImageLayer({
  url: serviceUrl,
  customParameters: {
    "token": "my-token"
  }
});

 

0 Kudos