Generate Token SSL Response

728
1
10-04-2018 01:42 PM
WilliamLanza
New Contributor

Hi, I am trying to generate a token via a java web app. It works on some servers, but on others I get a response that I don't expect (happens via the app and when posting directly in a browser:

 

Request looks like this:

 

http://localhost:6080/arcgis/admin/generateToken?username=myuser&password=mypwd&f=json&client=reques...

or this:

https://localhost:6443/arcgis/admin/generateToken?username=myuser&password=mypwd&f=json&client=reque...

 

Response looks like this:

{"ssl":{"supportsSSL":true,"sslPort":6443}}

 

as opposed to what I expect:

{"token":"U4rudliz0r6yQG2esK1Mcha8utQ-6XQVJG5iTHH8we2HHx1JR6MA52g3FYXuMVCX","expires":"1538503485453"}

The response doesn't indicate it's an error. So I'm a little confused.

Also, if, on the problem servers, I go to the UI for generating a token (http://localhost:6080/arcgis/admin), it generates a token correctly.

Is there some sort of configuration in ArcServer that needs setting? I don't see anything blatantly different when I compare working vs non-working server configurations.

 

Thanks in advance#

Tags (2)
0 Kudos
1 Reply
by Anonymous User
Not applicable

I know this is old and is for Javascript API - though having the same issue and solving it in python I thought I'd provide the answer to anyone else that searches for the {'ssl': {'supportsSSL': True, 'sslPort': 6443}} return and finds this question.

I came into this problem when updating python2 scripts to python3 and getting tired of all the encoding that urllib requires for it to work.  I changed the package I am using from 'urllib (  , 2 and 3)' to the 'requests' package.  The requests package makes it super simple and clean-

token = requests.get(url, query_dict).json()

For me, it was that I was using a GET request for the Token when the server is not set up for that request.  Changing it to a POST request fixed it.

token = requests.post(url, query_dict).json()

So maybe the culprit servers are not set up for the type of request is being sent.  This article provided the information to find what I had wrong-

Enable token acquisition through an HTTP GET request—Documentation (10.4) | ArcGIS Enterprise  and cautions against the GET request method:

Caution:

Although using a GET request is a convenient method of acquiring a token, a user's credentials are provided as part of the URL and may be stored in browser history or in network components. It's recommended that you update your applications so that tokens are not acquired through a GET request.

0 Kudos