How do you set an application to login and get secure content from AGOL? There seems to be some documentation and a new Credential class in the beta, but I am not sure how to do this.
Hi Thomas,
here you are:
Portal portal = new Portal("http://www.arcgis.com"); UserCredential credentials = new UserCredential("LogiCaseSensitive", "PasswordCaseSensitive"); portal.setCredential(credentials); portal.loadAsync(); portal.addDoneLoadingListener(new Runnable() { @Override public void run() { if (portal.getLoadStatus() == LoadStatus.LOADED) { ListenableFuture<PortalUserContent> content = portal.getPortalUser().fetchContentAsync(); content.addDoneListener(new Runnable() { @Override public void run() { try { PortalUserContent myContent = content.get(); for (PortalItem item : myContent.getItems()) { System.out.println("item title " + item.getTitle()); } } catch (InterruptedException | ExecutionException ex) { Logger.getLogger(QuartzBeta2.class.getName()).log(Level.SEVERE, null, ex); } } }); } } });
More details on: Access portal content—ArcGIS Runtime SDK for Java (Quartz Beta) | ArcGIS for Developers
Regards,
Adam
Thank you
Sorry, just checked my email.
Thank you so much.
I am sorry I was not clear. I am interested in getting content that is assigned to a specific group in my organizational account and therefore I have two options. These are OAuth 2.0 authentication and app login. The only reference I can find is at Use OAuth 2.0 authentication—ArcGIS Runtime SDK for Java | ArcGIS for Developers . But, looking at the Quartz java API reference I can only find a class called Credentials for portal. In it, there is a setCredential from json string something like the code below. I am wondering if this is the way to use the client id and client secret for an app to login to AGOL to get secured content. If it is, I need to know how to format the json string so I can automatically get content. If this is not the way to do it I need some guidance.
I want to create an offline/online app but the content that get delivered to the application has to be secure and from AGOL. Any help is appreciated.
final Portal portal = new Portal("http://www.arcgis.com", true);
portal.setCredential(Credential.fromJson("")); /
Thanks,
Tom
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.