Skip to content

add support for google people api #110

@ocarballo

Description

@ocarballo

Hi there. We found the need to invoke google people api ( https://developers.google.com/people/ ) as we want to retrieve information from users when logging in our app, even if they don't have a google plus profile.
In order to achieve that we needed use google api client, as with the rest operations (restTemplate) provided by spring social the mapping from the json received from the api to com.google.api.services.people.v1.model.Person was not done correctly, while the client was doing the mapping smoothly.
We would like to contribute adding a PeopleOperations invoking the people api and retrieving google account info, but that would actually break the pattern that spring social follows, as we wouldn't use restTemplate for that.
Our code looks like following:

`@Component
public class GooglePeopleClient {

private HttpTransport httpTransport;

private JacksonFactory jsonFactory;

@Autowired
public GooglePeopleClient(HttpTransport httpTransport,
                          JacksonFactory jsonFactory) {
    this.httpTransport = httpTransport;
    this.jsonFactory = jsonFactory;
}

public Person person(String token) {
    GoogleCredential credential = new GoogleCredential.Builder().build().setAccessToken(token);
    PeopleService peopleService =
            new PeopleService.Builder(httpTransport, jsonFactory, credential).build();
    try {
        return peopleService.people().get("people/me")
                .setPersonFields("birthdays,genders,names,photos,emailAddresses,phoneNumbers")
                .execute();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

}`

but we would like to wrap this in a peopleOperations so this is hidden behind spring social for a more consistent approach.

Before we start forking, and doing something with spring social I would like to get some feedback from you guys and see what you think about the approach.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions