Select to view content in your preferred language

Accessing a secured layer from C#  a console app

806
1
09-04-2012 07:44 AM
JasonCleaver
Frequent Contributor
Is it possible to access a secured service from a C# console application?  I am able to generate a token, however after reading the documentation the referer parameter is for webapps only. 

[TABLE="class: detailTABLE"]
[TD="class: detailTABLE"]client[/TD]
[TD="class: detailTABLE"]Description: The client identification type for which the token is to be generated.

  • If the value is specified as referer, the referer parameter must be specified.

The default and only value supported is referer
[/TD]refererDescription: The base url of the webapp that will invoke the Portal API. This parameter must be specified if the value of the client parameter is referer

Example: referer=http://myserver/mywebapp
[/TABLE]
Tags (2)
0 Kudos
1 Reply
MikeMinami
Esri Notable Contributor
The referer passed into the generateToken call must be contained within the referer header passed in with each call. So if generate token is called with referer=acme.com all calls using it must have a HTTP Referer header that contains that string, for instance �??http://maps.acme.com/mypage.html�??. Browsers automatically set this to whatever page the call is coming from and this cannot be overridden.

If the token is requested and used from C# then you can set whatever you want, and just make sure that the calls made to the API contain the same Referer string as was used to get the token. It could be a url, a session id, or whatever.

Thanks,

Mike
0 Kudos