Java Client for the Google+ API

October 10, 2011

I decided that I can make a separate java client library for Google+ (since I was a bit unhappy with what Google have provided for Java developers: no maven dependency, not quite easy to use, not getting updated with the API latest additions, example project using jsp scriptlets).

The project is (not too creatively) called “google-plus-java-api” and can be found (including a “getting started” guide) on GitHub. I am already using it in production for some simple G+ features in my startup, and so I will be updating it whenever Google add more methods, or change something (which I hope won’t happen too often)

The project home page shows a sample code to get started. The It’s very similar to other REST API clients like twitter4j, linkedin4j, restfb, other spring social clients. The idea is to be simple and straightforward to use. It has a couple of dependencies, so here are few notes trying to justify them:

  • the library is based on spring-social. It provides a good OAuth2 support (although I had to make some customizations in order to support refresh tokens), and a RestTemplate to simplify rest invocations. The downside is that it fetches some more spring dependencies – spring-web, spring-core, spring-beans and spring-context. This may be problematic for android users, but in general spring-social runs fine on android
  • Jackson is used for JSON deserialization. I’ve seen benchmarks hinting that Jackson is the fastest out there, but either way it is widely adopted and working. It seems to also be working on android. In fact, you can use any json provider as long as you implement a message converter (there’s only a jackson converter built-in)
  • Apache http components are used for the underlying http communication. Again, industry standard. If you don’t want to use it, you can remove it from the classpath and the library will revert to a built-in simple handler.
  • joda-time is used to represent dates. While it may seem a bit aggressive to force joda-time, I consider it a plus – it introduces a library that every project must use anyway
  • slf4j – delegates to whatever logging framework your project is using. (There isn’t much logging happening at the moment though)

If using maven these dependencies will be fetched automatically. Currently only a snapshot is available from the sonatype repository.

The library is still in early development, but as I noted, it is and will be used by me in production, so I’ll be fixing issues quickly when they appear. Currently I’m low on automated tests, but that should improve as well. Any feedback or contributions are welcome.

If you find the content interesting, you can subscribe and get updates


 

3 Responses to “Java Client for the Google+ API”

  1. Hey, I posted a comment on a different entry accidentally :-) http://techblog.bozho.net/?p=578#comment-7114

  2. Hi Bozho,

    I have been working on the Spring Social Google project: https://github.com/guznik/spring-social-google which so far abstracts access to Google+, Google Contacts and just started to work on Picasa.

    I would appreciate any feedback you may have on it and any insights you may have from comparing our work so far. I will also check out what you have done.

  3. Hi Gabriel,

    I didn’t find your project, otherwise I would have just contributed to it instead. But having two clients isn’t that bad anyway.

    For now, I see your your GoogleImpl taking only an access token – how do you handle refresh tokens?

Leave a Reply