ArcGIS API for JavaScript

925
5
04-20-2020 08:25 AM
MeghanKulkarni
New Contributor III

Hello,

Is there a way to access available token in ArcGIS API for JavaScript so that it can be appended to each XMLHttpRequest? 

The issue here is whenever map's load dojo event triggers, I seeToken required (499) response after which ArcGIS JavaScript API internally creates token and appends it to each following XMLHttpRequest.

A little bit of background. Portal for ArcGIS is federated with ArcGIS Server with Web Tier (IWA Authentication). Application consuming REST Services is ASP.Net.

Thanks

Meghan Kulkarni

0 Kudos
5 Replies
BenElan
Esri Contributor

Most of the security workflows happen in the IdentityManager module. You can generate and register tokens there.

MeghanKulkarni
New Contributor III

Hello Ben,

Thanks for your reply. Can you provide 3.x version API reference link, please?

Meghan Kulkarni

0 Kudos
BenElan
Esri Contributor

Sure, here is the reference for 3x: IdentityManager | API Reference | ArcGIS API for JavaScript 3.32 

3x has the same generate/register functions for tokens

0 Kudos
MeghanKulkarni
New Contributor III

Hello Ben,

I don't think I can use the OAuth protocol. The consuming application is based on ASP.NET.  Here's an example request for obtaining Legend of a map

https://<domain>/server/rest/services/SC/MapServer/0/images/4416e96c2b84a29886cd03bf8edb2fa9

Each Time I get 302 HTTP error code since it does not have token info. When I open a separate window it does resolve since I've access to this content. 

I believe the reason being ArcGIS server internally sets cookie 'agstoken' for each subsequent request. I verified this in the Cookies section in Chrome's Dev Tools. Is there a way to do this JavaScript?

Thanks.

Meghan Kulkarni

0 Kudos
BenElan
Esri Contributor

Hi Megan,

302 HTTP status codes aren't usually associated with a token issue. There may be something else going on here. I'd suggest contacting Esri Support Services so an analyst can take a closer look.

Ben

0 Kudos