Monday, April 9, 2012

Spring Social Google First Milestone Is Out



I'm happy to announce that the first milestone of Spring Social Google is out! Since the project started I received a lot of feedback from the community that helped shape this milestone and I would like to thank everyone who helped with suggestions, bug reports, patches and kind words.

This milestone includes integration with Google+, Portable Contacts and Google Tasks. It also lets you integrate with the GData Java Client Library, letting you use Spring Social Google for authentication and authorization, and applying the OAuth2 access token to an instance of a GData client. Please see the reference manual for usage instructions.

The example application demonstrates most of the available functionality. You can see it in action here.

To use Spring Social Google in a maven project, add the following repository and dependency to your pom.xml :

<repository>
    <id>spring.social.google</id>
    <name>Spring Social Google</name>
    <url>https://github.com/GabiAxel/maven/raw/master/</url>
</repository>

...

<dependency>
    <groupId>org.springframework.social</groupId>
    <artifactId>spring-social-google</artifactId>
    <version>1.0.0.M1</version>
</dependency>


or download the JAR here.

The project roadmap mostly depends on community feedback. Integration with more Google APIs will be added and you can help decide which will be first, so let me know what you think.

Enjoy using Spring Social Google!

21 comments:

  1. Hi,I find that the emails of googleplus's friends are always null.May be the reason is that the portable contacts do not return email address.And Google now suggest Contacts V3 to replace the portable Contacts. Can you add it?

    ReplyDelete
  2. Hi Gerald,

    Actually I started with GData Contacts V3, but it had its own problems, to name a few: the contact and group IDs are specific to the logged in user, the picture URL requires authentication, and working with Atom is very cumbersome.

    Indeed Google+ API is not complete yet, and Google Portable Contacts has been deprecated. Google considers using PoCo format for the Contacts and G+ APIs, and when it does I will update the library.

    If you want to work with GData API, you may integrate Google's Java client libraries with Spring Social Google by instantiating a subclass of Service (eg. ContactsService) and sending it to Google.applyAuthentication() method.

    ReplyDelete
  3. Thanks for your suggestion, I will try integrating GData and Spring Social Google.

    ReplyDelete
  4. Hi,
    Thanks for the great work. I am running into a slight problem.
    If I want to make un-authenticated calls to Google+ I can instantiate an GoogleTemplate with the default constructor. However, when I try to access any public info, I get a 403 forbidden error.

    I was wondering that in the case of un-authenticated access, one still needs to provide the API key. But I cant figure out how that is accomplished.

    Thanks

    ReplyDelete
  5. Thanks for this release.
    I'm using this version of spring-social-google but when I make an activities search I'm getting null Content, when I do "List activityList = page.getItems();" all Activity objects in List doesn't have content property. I post a more detailed description of this in http://forum.springsource.org/showthread.php?130602-Spring-Social-Web-Activity-object-without-content-when-Accessing-with-OAuth2

    Could you help me with this?

    ReplyDelete
  6. Hi, I can't seem to access email addresses from Persons anymore. Also getting 404s on open social endpoints, so I'm assuming that they are end of life. Just wondering how to get the email addresses from Persons that you retrieve through your network (or gmail inbox)

    ReplyDelete
    Replies
    1. Hi mschipperheyn,
      To work with Google Contacts, use GData Java Library, and you can use Google.applyAuthentication() to use Spring Social's authentication mechanism with it.

      Delete
    2. Ok, I had a look at that. Not the most user friendly library. I'm also not entirely sure why this isn't part of Spring Social Google anymore. Is there a specific reason for using GData to do parts of the interaction with Google or is it more of an "I haven't gotten around to it yet"

      Delete
    3. I decided to include integration only to new JSON-based APIs. At the time PoCo was in experimental stage and I hoped it would become stable but it got deprecated, so it's out of the library too.
      The GData APIs are so much more complex than the new JSON ones (understand that it's not the Java library that is complex, it's the API itself) that I didn't see a benefit in integrating with them (after working with them for a while), and providing a generic integration with the GData Java library seems like the best solution.

      Delete
    4. Right, it's a shame really that the ease of use of the library on some key features (for me) has disappeared. Some small code examples to get started would be appreciated. Thanks

      Delete
    5. There is an example in the manual for use of applyAuthentication() https://github.com/GabiAxel/spring-social-google/wiki/Spring-Social-Google-Reference-Manual use it with GData Contacts Java library.

      Delete
  7. Hi Garbiel,

    Love your work. Currently trying to use the DriveOperations component of library.

    public DriveFile upload(Resource resource, DriveFile metadata, UploadParameters parameters)

    I'm not a Spring GURU, but how can we easily convert a file uploaded via [input type="file"] to a Spring Resource?

    Some code examples would be greatly appreciated. Happy to contribute it back to doco/quickstart

    ReplyDelete
    Replies
    1. Hi SurtaX,

      The most convenient way in my opinion to do upload with SpringMVC is to add MultipartFile parameter to your controller method. MultipartFile has getBytes() and getInputStream() methods which you can use with the constructors of ByteArrayResource and InputStreamResource.

      <input type="file" name="myfile"/>

      @RequestMapping(method=POST)
      public void uploadMethod(MultipartFile myfile) {
      Resource resource = new InputStreamResource(myfile.getInputStream());
      }

      Delete
    2. Brilliant. I'll give that a go, thanks for the response!

      Again thanks for the awesome work. Having lots of fun with Spring Social Google :D

      Delete
    3. Arghh sorry to trouble you again. But I'm hitting into a Mimetype issue when trying to upload. Here's my code and server log:
      Resource resource = new InputStreamResource(uploadItem.getFileData().getInputStream());
      DriveOperations drive = google.driveOperations();
      UploadParameters params = new UploadParameters();
      DriveFile.Builder builder = new DriveFile.Builder();
      builder.setTitle("Test FileName").setDescription("description").setMimeType("application/octet-stream");
      drive.upload(resource, builder.build(), params);

      Delete
    4. java.lang.NullPointerException

      at javax.activation.MimetypesFileTypeMap.getContentType(MimetypesFileTypeMap.java:307)
      at org.springframework.http.converter.ResourceHttpMessageConverter$ActivationMediaTypeFactory.getMediaType(ResourceHttpMessageConverter.java:130)
      at org.springframework.http.converter.ResourceHttpMessageConverter.getDefaultContentType(ResourceHttpMessageConverter.java:71)
      at org.springframework.http.converter.ResourceHttpMessageConverter.getDefaultContentType(ResourceHttpMessageConverter.java:1)
      at org.springframework.http.converter.AbstractHttpMessageConverter.write(AbstractHttpMessageConverter.java:167)
      at org.springframework.http.converter.FormHttpMessageConverter.writePart(FormHttpMessageConverter.java:306)
      at org.springframework.http.converter.FormHttpMessageConverter.writeParts(FormHttpMessageConverter.java:270)
      at org.springframework.http.converter.FormHttpMessageConverter.writeMultipart(FormHttpMessageConverter.java:260)
      at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:200)
      at org.springframework.http.converter.FormHttpMessageConverter.write(FormHttpMessageConverter.java:1)
      at org.springframework.web.client.RestTemplate$HttpEntityRequestCallback.doWithRequest(RestTemplate.java:588)
      at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:436)
      at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:401)
      at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:377)
      at org.springframework.social.google.api.drive.impl.DriveTemplate.upload(DriveTemplate.java:136)
      at org.springframework.social.quickstart.HomeController.create(HomeController.java:614)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      at java.lang.reflect.Method.invoke(Method.java:616)
      at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
      at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
      at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
      at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)

      Delete
  8. I recently saw an oauth popup that in stead of the standard Google version contained a Google+ specific version, allowing you to notify friends in certain circles etc. I wonder if something like this is possible with spring social google?

    ReplyDelete
    Replies
    1. I assume you are referring to App Activities, or Moments ( https://developers.google.com/+/api/latest/moments ), and yes I am working on this for the coming milestone.

      Delete
  9. Hi there,

    The link to the example application on github and the link to the live example gives a 404 error? Are they available from somewhere else?

    ReplyDelete
  10. Hi,

    is this project still currently mantained?

    ReplyDelete
  11. I am using spring social,in this facebook and twitter apis are creating/updating record in userconnection table but this google api doesn't,and providinng error not connected to goole.
    can u please tell me the reason?

    ReplyDelete