ArcGIS Server Login

421
5
12-19-2023 04:21 AM
Wade
by
New Contributor III

I use ArcGIS JS version 4.27. I have an ArcGIS Server but it requires logging in to see the layers.
I would like to ask how I can directly use my account and password to log in to this ArcGIS Server in JS and obtain the layers directly?

0 Kudos
5 Replies
BryanMc
Occasional Contributor

There are 4 main authentication methods you can use to access secure resources. Access secure resources | Overview | ArcGIS Maps SDK for JavaScript 4.28 | ArcGIS Developers

One approach is to create a simple Reverse Proxy. Save credentials in a server config/env file and setup urlUtils to use the proxy for specific services. Esri historically had a proxy sample you could use, but it isn't maintained anymore - but you could create your own basic RP pretty easily to handle this. The Esri sample is still online but they are pretty clear you should use something else "Do NOT use these proxies. They have not been maintained or supported for a long time."

0 Kudos
Wade
by
New Contributor III

Hi @BryanMc , At present, I think the token validity period is too short and can only last for two weeks. How can I set up a simple reverse proxy to solve this problem?

0 Kudos
BryanMc
Occasional Contributor

Hi @Wade , You can just extend the length of a long token in ArcGIS Server settings. There are some pros and cons of using this approach, but it is pretty easy to configure. This article has all the details (oldie but a goodie):ArcGIS for Server Long Tokens (spatialtimes.com) . I wrote that many years ago, but I just logged into an ArcGIS Server 10.9.1 instance and the setting is still there to modify.

As for the proxy approach, there are lots of examples out there for different languages (.NET, PHP, Java, Node.js, etc). This will depend on your server platform and what you feel comfortable with so hard to give a relevant example.

Both methods above can work with ArcGIS Server standalone. If you have access to Portal, Esri ArcGIS Server help pages do explain how to leverage Portal/AGOL for accessing secure services (with credentials saved in the item): Connect to secure services—ArcGIS Server | Documentation for ArcGIS Enterprise.

 

0 Kudos
Wade
by
New Contributor III

@BryanMc Thanks for providing the method. However, the service setting authority no longer belongs to us, so I would like to ask if I can use RP to directly log in to the account to solve this problem.

We mainly develop NET6 and will take a look at Esri's early Proxy research.

0 Kudos
BryanMc
Occasional Contributor

We use a modified version of the DotNet one that was archived. Not sure about the final one listed here but looks like it covers many situations: https://github.com/Esri/resource-proxy

0 Kudos