Frage

I am working on a small Java Swing based application, and want to add a decorative feature in it to sync files with Google Drive. But, all the documentation / discussions about Google API's that I see talks about putting this code into a web application. Also, the credentials of the client on https://cloud.google.com/console require the origin URL, without which the API will not work.

I know I can either embed a Jetty or take the hard way of sending and receiving HTTP requests. But either would be an overkill for this petty application that I am making. So, I was wondering if there is a way to include a Jar file that just lets me login and then access the folders on the Google drive.

Do you know of one? Is this possible with the existing API's? Thanks for your help!

War es hilfreich?

Lösung

If you have a look at the detailed installation instructions then there is a section for general purpose java applications. That is your case.

The following are the jars from the dependencies folder required for general purpose Java 5 applications (or a newer compatible version of each dependency):

  • google-api-client-1.17.0-rc.jar
  • google-oauth-client-1.17.0-rc.jar
  • google-http-client-1.17.0-rc.jar
  • commons-logging-1.1.1.jar
  • gson-2.1.jar httpclient-4.0.3.jar
  • httpcore-4.0.1.jar
  • jackson-core-2.1.3.jar
  • jsr305-1.3.9.jar
  • protobuf-java-2.2.0.jar
  • xpp3-1.1.4c.jar

You can use the GooglePromptReceiver to ask the end user to paste the authorization code from the browser to your application. You can find examples in the samples. The cmdline samples apply to your case.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top