Hi guys,
I'd like to generate token for arcgisonline hosted service but I can figure out the endpoint and how to construct the request.
What is the endpoint and how would I construct the parameters. I'm using Java HttpUrlConnection? #ArcGISREST
Solved! Go to Solution.
Request:
POST https://www.arcgis.com/sharing/generateToken HTTP/1.1
Host: www.arcgis.com
Content-Type: application/x-www-form-urlencoded
f=json&username=USERNAME&password=PASSWORD&client=requestip
Response:
HTTP/1.1 200 OK
Date: Thu, 01 Mar 2018 09:53:04 GMT
Content-Type: text/plain;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Origin
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Vary: Accept-Encoding, User-Agent
X-Robots-Tag: noindex
{"token":"TOKEN","expires":1519905184244,"ssl":false}
Steve,
Please refer:
Acquiring ArcGIS tokens—ArcGIS Server Administration (Windows) | ArcGIS Enterprise
~Shan
I have seen this, and for ArcGIS Server this is okay. However, I'd like to know which endpoint does ArcGIS Online use to generate tokens for username and password based authentication.
I know there is this option Get an access token | ArcGIS for Developers which is based on CLIENT_ID and CLIENT_SECRET. But I want to use my password and username to get the token from ArcGIS online.
Use POST instead of GET.
Yes I need to use POST. But what is the right endpoint?
Request:
POST https://www.arcgis.com/sharing/generateToken HTTP/1.1
Host: www.arcgis.com
Content-Type: application/x-www-form-urlencoded
f=json&username=USERNAME&password=PASSWORD&client=requestip
Response:
HTTP/1.1 200 OK
Date: Thu, 01 Mar 2018 09:53:04 GMT
Content-Type: text/plain;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Origin
Cache-Control: no-cache
Pragma: no-cache
Expires: -1
Vary: Accept-Encoding, User-Agent
X-Robots-Tag: noindex
{"token":"TOKEN","expires":1519905184244,"ssl":false}
Thank you ramunask I just tried in Postman and it works.
How do you include the post conditions into the URL? I keep getting the following error:
{"error":{"code":400,"messageCode":"GWM_0002","message":"Invalid URL","details":[]}}
My URL looks like this:
https://www.arcgis.com/sharing/generateToken HTTP/1.1?f=json&username=USERNAME&password=PASSWORD&client=requestip
HI @joe your URL should look like this instead
https://www.arcgis.com/sharing/generateToken?f=json&username=USERNAME&password=PASSWORD
This is suffi...
Hi dear all,
I been trying to do that request too, using postman but I get an error: {"error":{"code":400,"message":"Unable to generate token.","details":["POST request should not contain username and password in the query string."]}
Can anybody help me to solve this, please?
Best regards,