microsoft / vsts-authentication-library-for-java

Retrieve OAuth2 or Personal Accesss Tokens for Visual Studio Team Services (visualstudio.com) accounts. Also provides secure storage for those secrets on different platforms.
MIT License
18 stars 20 forks source link

Step by Step Instructions for hooking library to run with Java App in Eclipse #17

Open findaway007 opened 6 years ago

findaway007 commented 6 years ago

This might be a user issue as opposed to your library.

I'm new to Eclipse and Git and have been attempting to run a call from a java application to connect and run a rest API call. Unfortunately, I haven't been successful for over 2 weeks. Here's what I have done so far:

  1. Created an app that will retrieve test cases for a date range in VSTS and retrieve outcome info
    • This works, but I'm using files for this stage of the effort a. The files were copied from an API call using the browser which is already authenticated, so no issues here
  2. Captured Azure access information to allow a client application to connect (client id, application id, ...)
  3. Imported various jar files ranging from jackson to javax.ws.rs-api.2.0.jar
  4. Imported your vsts-authentication-library-for-java to a 'general project' via Git
  5. Copied over the common, config, core, providers, storage folders... and support files from the vsts-author... general project... into the java project in hopes of using the vsts-author... classes to connect.

On step 4, I'm not sure if the process above is incorrect in Eclipse. Our team is excited about using Java to extract information from VSTS via rest-API calls. At this point, your library looks like the key. If you have a procedure or step by step information, it would be greatly appreciated.

findaway007 commented 6 years ago

Figured out the access to library issue...MOSTLY. For those that don't know the maven process in Eclipse, here's it is:

  1. Originally Developed the program in Java Project and used static files for my process

  2. Convert the Java project to a Maven Project (Right click project --> Configure --> Convert to Maven)

    • Key reason is to gtet a pom.xml file
  3. Copied the targeted dependency identified in the README.md file

    com.microsoft.alm auth-providers 0.6.3
  4. Compiled the project which generated a pom.xml file

  5. Updated the pom.xml file to include the above dependency

    • inserted above the bottom of the file's end tag

      com.microsoft.alm auth-providers 0.6.3

      Note: To update the pom.xml file in eclipse, double click on the pom.xml file. Then select the pom.xml file tab found at the bottom on the far right.

  6. Added the vsts-authentication-library-for-java import statements found in the sample java programapp.java

  7. The below imports could not be resolved, so I'm currently trying to find jar files for them import com.microsoft.alm.sourcecontrol.webapi.GitHttpClient; import com.microsoft.alm.sourcecontrol.webapi.model.GitRepository; import com.microsoft.alm.storage.StorageProvider; import com.microsoft.alm.storage.StorageProvider.SecureOption; import com.microsoft.visualstudio.services.account.Account; import com.microsoft.visualstudio.services.account.AccountHttpClient;

STATUS: ...trying to find the JAR file(s) for the above 6 imports.

findaway007 commented 6 years ago

Able to find 2 more imports to resolve in the app.java sample code by including all of the maven dependencies found in the README.md: import com.microsoft.alm.storage.StorageProvider; import com.microsoft.alm.storage.StorageProvider.SecureOption;

Now searching for the remaining 4 jar file(s) for the remaining 4 imports statements: import com.microsoft.alm.sourcecontrol.webapi.GitHttpClient; import com.microsoft.alm.sourcecontrol.webapi.model.GitRepository; import com.microsoft.visualstudio.services.account.Account; import com.microsoft.visualstudio.services.account.AccountHttpClient;

findaway007 commented 6 years ago

Conclusion:

Upgraded both eclipse and IntelliJ to the latest version and STILL the above 4 imports still didn't resolve. Scoured the internet for the JAR files for these and didn't find them. My conclusion is that this library DOES NOT support Java being authenticated to access VSTS as promised. It's missing key JAR files needed that should be included in the POM.xml file dependencies section.

It's interesting that the C# version DOES resolve the imports with lots of documentation. I wonder if AWS supports java applications accessing their platform tools...

lylam2008 commented 4 years ago

You need to check out the repository "vsts-authentication-library-for-java" to build everything, including the example. If you want to run the Test App in Eclipse, you can import the mentioned repository as a Maven project.