Token Security on an ArcGIS Server (Javascript)

12563
23
06-29-2011 01:26 AM
GrahamWhelan
New Contributor
Hello

I have a javascript application that connects to an ArcGIS server and does some functionality with the feature services. Today we added token based security to the rest end point which means I can no longer access it without the appropriate login details.

Can anyone provide a code example in javascript or point me in the direction of an example, of how to get a token using login details and store it/use it for a defined period of time. I cant find anything on the resource center.

Thanks in advance.

Graham
0 Kudos
23 Replies
nicogis
MVP Frequent Contributor
Open in visual studio the application where there is your proxy and you try go in debug
0 Kudos
VIKRANTKRISHNA
New Contributor III
I got an error when I debug the proxy.ashx

error message screenshot is attached.
0 Kudos
nicogis
MVP Frequent Contributor
when you go in debug you provide a url after http://.../proxy.ashx ->  http://.../proxy.ashx?http://yourrequest
0 Kudos
BrettGreenfield__DNR_
Occasional Contributor II
I got an error when I debug the proxy.ashx

error message screenshot is attached.


Were you ever able to solve this issue?  I get the same thing when I try to access http://localhost/proxy/proxy.ashx, and anytime I try to access a service through the proxy page I get an error 403.
0 Kudos
JohnGravois
Frequent Contributor
are you working with the sample ASP.NET proxy from the Javascript resource center?  if you haven't already, please try setting the global flag "mustMatch" to false to see whether you can forward traffic to a standard webpage directly from the browser.

ie:
http://localhost/proxy/proxy.ashx?http://esri.com
0 Kudos
BrettGreenfield__DNR_
Occasional Contributor II
Yep - that's the one I'm using.  I tried setting mustMatch to false and I'm still unable to connect to anything.

When I try to connect directly to localhost/proxy/proxy.ashx I get the same error page that vikrant327 posted.  I tried turning debugging on and it gave me the error message in the attached screenshot.

[ATTACH=CONFIG]17381[/ATTACH]

I'm guessing I'm just doing something stupid here!
0 Kudos
JohnGravois
Frequent Contributor
its normal to see an error when you try to access the proxy without attempting to forward a url, but you should definitely be able to forward traffic if you aren't restricting sites.

did you convert the proxy folder to an application in IIS?
0 Kudos
BrettGreenfield__DNR_
Occasional Contributor II
I did, and just to be sure I tried doing so again.  One thing I'm noticing this time, when I click Convert to Application and try the "Test Settings" button, I get an error that says "Invalid Application Path", even though the physical path is pointing directly to C:\inetpub\wwwroot\proxy.

I apologize if these are dumb questions - I'm really out of my element working with this stuff!
0 Kudos
JohnGravois
Frequent Contributor
i just did a quick test and it seems that an "invalid application path" error when converting an application is normal for working proxies as well.

in IIS manager, do you have handler mappings for .ashx files?
0 Kudos
BrettGreenfield__DNR_
Occasional Contributor II
I have three of them - SimpleHandlerFactory - Integrated; SimpleHandlerFactory-ISAPI-2.0; and SimpleHandlerFactory-ISAPI-2.0-64.
0 Kudos