POST
|
And in case it can help save anybody else from working to figure this out, here's the code I'm using to create ArcGIS tokens (not OAuth2). You will need to modify it if you're using client IDs and not just referer. I've been using this to successfully access token-secured geoprocessing services. private static UserCredential tokenFromJson(String tokenJson, String referer) { JsonParser parser = new JsonParser(); JsonObject obj = parser.parse(tokenJson).getAsJsonObject(); String tokenValue = obj.get("token").getAsString(); long expiration = obj.get("expires").getAsLong(); Instant expirationInstant = Instant.ofEpochMilli(expiration); if (expirationInstant.isBefore(Instant.now())) { //token is expired. System.out.println("Token expired at " + expirationInstant); return null; } UserCredential cred = UserCredential.createFromToken(tokenValue, referer); return cred; } public static UserCredential createToken(UserCredential cred, URL tokenGenUrl, String referer, int expirationMins) { try { String tokenJSON = null; HttpsURLConnection conn = (HttpsURLConnection)tokenGenUrl.openConnection(); final String charset = "UTF-8"; String urlParameters = "username=" + cred.getUsername() + "&password=" + cred.getPassword() + "&client=" + "referer" + "&referer=" + referer + "&expiration=" + expirationMins + "&f=json"; System.out.println(urlParameters); conn.setRequestMethod("POST"); conn.setRequestProperty("Accept-Charset", charset); conn.setRequestProperty("Content-Length", "" + Integer.toString(urlParameters.getBytes().length)); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); OutputStream wr = conn.getOutputStream(); wr.write(urlParameters.getBytes()); BufferedReader in = new BufferedReader( new InputStreamReader(conn.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); wr.close(); tokenJSON = response.toString(); System.out.println("Generating new query from service"); UserCredential tokenCred = tokenFromJson(tokenJSON, referer); return tokenCred; } catch (IOException e) { e.printStackTrace(); } return null; }
... View more
04-17-2019
08:06 PM
|
0
|
0
|
569
|
POST
|
If I create a long-running async GeoprocessingJob job and save the job ID, can I use that job ID to initialize a new GeoprocessingJob in a subsequent execution of my program?
... View more
04-17-2019
03:22 PM
|
0
|
0
|
255
|
POST
|
Hi Eric, Sorry I didn't notice when you replied to this almost a year ago. From the first link you provided, I was able to find the following reference to ArcGIS Tokens (bolded below, but no description of how to obtain one through the API: The ArcGIS Runtime SDK provides full support for access to secured ArcGIS Server, ArcGIS Online, or ArcGIS Enterprise resources using the following authorization methods: ArcGIS Tokens: proprietary token-based authentication mechanism. OAuth 2.0: secure delegated access to server resources. Web-tier security: HTTP secured service / Integrated Windows Authentication (IWA). Certificate: Public Key Infrastructure (PKI). This is different from OAuth2 - I'm talking about the ArcGIS proprietary tokens obtained as described on this page. I'm looking for how to do in Java something similar to what is demonstrated in this .NET example. In the current 100.5.0 version of the Java SDK, I still don't see any straightforward way to do this. I've been writing my own HTTP code to send POST requests to the /generateToken service. Am I missing anything in the API or documentation that says how to do this?
... View more
04-15-2019
09:49 PM
|
0
|
0
|
569
|
POST
|
I'm trying to authenticate with an ArcGIS Enterprise Portal using ArcGIS Tokens (not OAuth). It looks like the most recent version of the SDK added some capabilities in this area, such as the new method UserCredential.createFromToken(). But it is still unclear how to use this within the context of an AuthenticationManager. What is the recommended process for obtaining tokens for an ArcGIS Enterprise portal? I know the URL of the Portal that I am connecting to, and the URL at which tokens are generated, but I don't see any intuitive way to pass a request to the token generation service. This is a follow-up to an older question asking the same thing for the Java SDK version 100.0.0. In the previous version, I determined through a help ticket that this capability had not yet been implemented. It looks like the capability might be implemented now, but I haven't found anything in the documentation to explain how to get the token. In the .NET SDK they have AuthenticationManager.Current.GenerateCredentialAsync; I don't see anything similar in the Java SDK. I'd really appreciate any guidance in figuring this out.
... View more
03-26-2018
09:28 PM
|
1
|
3
|
1198
|
POST
|
Adam Nicinski wrote: You can generate valid token at the ArcGIS Online service endpoint , but you need to somehow handle its refreshing and appending to ArcGIS Server endpoint requests, which in fact UserCredentials do for you. Can you please elaborate on how UserCredentials does this? I can't find any way to get a UserCredentials to handle tokens; if you know a way to do this, can you please post a few lines of code to demonstrate how it works?
... View more
03-20-2017
09:07 AM
|
0
|
1
|
710
|
POST
|
That's not what I'm looking for. That's just username and password. I need a way to handle token-based authentication, as described here: ArcGIS Security and Authentication | ArcGIS for Developers Token-based: Your app provides a valid user name and password for the user. In the response, you receive a token that is included with requests for secured content on the portal for authenticated resources. Available with ArcGIS Online and ArcGIS Enterprise version 10.2 or earlier. The UserCredential class can only store a username and password, not a token. Specifically what I'm looking for is: 1. How to connect to a token generation service to obtain a token? Is there anything like OAuthTokenCredentialRequest that will work for non-OAuth token generation? 2. Once I have a valid token, how to use the token to authenticate with a RemoteResource? Maybe a subclass of Credential that can store a token, so I can return it from my AuthenticationChallengeHandler.
... View more
03-17-2017
07:25 AM
|
0
|
3
|
710
|
POST
|
When I try to make calls to a token-secured RemoteResource using the new 100.0.0 API, I get an exception: "com.esri.arcgisruntime.io.JsonEmbeddedException: Token Required" Is there a way to add a Token to a UserCredentials object? In the 10.2.4, I would create a UserCredentials object, and simply call setUserToken(), but that method no longer exists. In the new API, the UserCredentials class only takes a username and a password. There is another type of Credential, OAuthTokenCredential, but this is not appropriate to my use case because I'm not using OAuth. How is non-OAuth token-based authentication handled in the new API?
... View more
03-16-2017
11:35 AM
|
0
|
5
|
1579
|
POST
|
Setting geometry on each graphic will indeed be slow after about a few hundred graphics. Thanks for the response, Eric. Is there any other way in Quartz to move lots of graphics (or is there planned to be a way) without slowdown like we can do in 10.2.4? It would be nice keep this functionality in Quartz.
... View more
09-26-2016
01:56 PM
|
0
|
0
|
604
|
POST
|
Thanks for the info. I'm working from the Java beta documentation here: Edit geometries. For now, I've managed to get things running a bit more smoothly by limiting the number of points that I draw, but I'd love to find a way to smoothly animate tens of thousands at a time like in 10.2.4. I was looking for a way to reach out to Eric, but couldn't find any contact info. Maybe he'll stumble across this post at some point.
... View more
09-26-2016
06:00 AM
|
0
|
2
|
604
|
POST
|
I'm trying to animate a large number of points in Quartz, similar to what is described in this presentation using the 10.2.4 (see slides 10-12): https://s3.amazonaws.com/webapps.esri.com/esri-proceedings/devsummit14/papers/dev-106.pdf In 10.2.4, we have movePointGraphic() for this purpose. I haven't been able to locate any similar function in layers or overlays in Quartz. In Quartz, it seems like Overlays are more well-suited to this kind of thing than feature layers, but I haven't been able to get them fast enough. I've tried using an overlay with a SimpleRenderer in dynamic mode to animate a large number of Point graphics by simply calling Graphic.setGeometry() on each point, and it is too slow. Is there some trick to this that I'm missing? Among the existing samples, I've only seen examples of updating a small handful of graphics at a time. Thanks for any help on this!
... View more
09-19-2016
06:55 PM
|
0
|
4
|
1498
|
Title | Kudos | Posted |
---|---|---|
1 | 03-26-2018 09:28 PM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|