Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for google people api #110

Open
ocarballo opened this issue Jul 18, 2017 · 1 comment
Open

add support for google people api #110

ocarballo opened this issue Jul 18, 2017 · 1 comment

Comments

@ocarballo
Copy link
Contributor

ocarballo commented Jul 18, 2017

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.

@ocarballo
Copy link
Contributor Author

Hi @GabiAxel . After seeing some of the comments in other issues we realized that you guys didn't want to add a new api binding.
I have created a PR with the changes I have done in order to invoke people api using rest template, following the existing pattern.
Please let me know your thoughts / review it. For the moment we have just added the fields we needed in our development.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant