Select to view content in your preferred language

Authentication using url and token

6661
6
07-29-2014 10:09 AM
MatthewAntognoli
New Contributor

Hi.

I am trying to use token based authentication to get access to a restricted map layer.

I can generate a token using the url:

https://<myserver>/arcgis/tokens/?request=gettoken&username=<my_user_name>&password=<my_password>&clientid=ref.http://<myserver>&expiration=1440

Then using the token in the url to access the map layer, I use:

https://<myserver>/arcgis/rest/services/AIR/MapServer/0‌?token=<mytoken>

But the url always redirects me to the 'ArcGIS Server REST API Login' screen. Can you help me with this by chance?

Thank you!

0 Kudos
6 Replies
MatthewAntognoli
New Contributor

I found a work around to this problem. By generating a token like this:

https://<myserver>/arcgis/tokens/?request=gettoken&username=<my_user_name>&password=<my_password>&http://<myserver>

I just cut out the clientid=ref. because I am not sure what should be used for 'ref.'  If you know, please let me know. Thank you.

0 Kudos
JarrettGreen
New Contributor III

I'm using an automated tool to verify my secure services are running and to email me if it get anything but an http 200 status code. The redirection to the login page throws a 302 status code. After generating the token and appending to my secure services, half of my services would return a 200 and half would return a 302. I found no pattern in hours of testing this.

I had added client=requestip at the end of my query string. I used your method and it seems to work 100% of the time. So bizarre, but thank you for the solution!

0 Kudos
WernerGaar
New Contributor

Hi @JarrettGreen , could you tell me which automated tool you are using? We are also trying to monitor if our secure services are running. Thanks!

0 Kudos
JarrettGreen
New Contributor III

@WernerGaar This went through several iterations, but I believe the first tool you ask about was Runscope. It was then migrated to a python script with custom http requests. We have since migrated these specific sets of services into ArcGIS Online and no longer require monitoring.

If I were to do this again, I'd look to use the ArcGIS Python API.

WernerGaar
New Contributor

Thanks for your reply!

0 Kudos
ElizabethNolan
New Contributor III

Thanks for this suggestion it ended up solving the issue that I was having, but I don't understand why...I am redirected one way and not the other. It is because of the HTTP GET instead of POST??? It must be. I would consider this a bug.

0 Kudos