Announcement Announcement Module
Collapse
No announcement yet.
New Project: Spring Social Google Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #46
    The way around it AFAIK is to write a custom controller that offers a special signin option for Google. Not very elegant to put it mildly.

    @Controller
    @RequestMapping("/signin")
    public class MySignInController extends ProviderSignInController {

    private final ConnectSupport webSupport = new ConnectSupport();
    private final ConnectionFactoryLocator connectionFactoryLocator;

    private final MultiValueMap<String,String> googleParams = new LinkedMultiValueMap<String,String>();

    public MySignInController(
    ConnectionFactoryLocator connectionFactoryLocator,
    UsersConnectionRepository usersConnectionRepository,
    SignInAdapter signInAdapter) {
    super(connectionFactoryLocator, usersConnectionRepository, signInAdapter);
    googleParams.add("access_type", "offline");
    googleParams.add("approval_prompt", "force");
    this.connectionFactoryLocator = connectionFactoryLocator;

    }

    @RequestMapping(value="/ext/google", method=RequestMethod.POST)
    public RedirectView googleSignIn(@PathVariable String providerId, NativeWebRequest request) {
    ConnectionFactory<?> connectionFactory = connectionFactoryLocator.getConnectionFactory(prov iderId);
    try {

    return new RedirectView(webSupport.buildOAuthUrl(connectionFa ctory, request, googleParams));
    } catch (Exception e) {
    return new RedirectView(URIBuilder.fromUri("/social/signin/").queryParam("error", "provider").build().toString(),true);
    }
    }
    The only problem I have is to get this Controller to work properly. Spring keeps trying to initialize it with a no-args constructor, even when I try to exclude annotations. Infuriating.

    dispatcher-servlet.xml
    <context:component-scan
    base-package="nl.project.webapp">
    <!-- exclude controllers that are picked up by Spring Social -->
    <context:exclude-filter type="annotation" expression="nl.project.webapp.social.MySignInContr oller"/>
    </context:component-scan>

    Comment


    • #47
      I hadn't replied to your original message because I was looking into making ProviderSignInController more flexible in this regard. But as you've discovered, a more immediate option (while I sort out what to do with PSIC) is to create your own sign in controller.

      As for the exclusion problem: You've got an annotation type exclude filter, but your expression refers to MySignInController. That would only work if MySignInController were an annotation and your controller (with a different name) were annotated with it. You'll want to use one of the other filter types, such as assignable (or aspectj or regex) to exclude the controller.

      BTW, since this problem is only tangentially related to Spring Social Google, perhaps it's time to start a new thread?

      Comment


      • #48
        did the guznik github repo move? It's not available anymore

        Comment


        • #49
          It's now at https://github.com/GabiAxel/spring-social-google

          Comment


          • #50
            Hey All,

            It looks like the latest version of spring-social-google removes a bunch of functionality like saving contacts and uploading contact photos. I see above that guznik is only working on this in his/her spare time. Does anyone know if these changes are pending soon or if I should consider implementing & submitting a push request?

            Thanks!
            Doug

            Comment


            • #51
              Spring Social Google is a community-led project with giznik/GabiAxel as the leader. I'm sure he'll welcome pull requests, as should any project leader; that's part of the community aspect of the projects!

              Comment


              • #52
                Hi Doug,

                I decided to drop GData support. GData APIs are very cumbersome and the Contacts API specifically seems problematic for the following reasons: 1) there is no reference from contact entries to corresponding Google profiles, and actually there is no global ID representing a contact, just an ID in the scope of the authenticated user, 2) to view photos you must be authenticated.

                Therefore I switched to Portable Contacts API. The API is a much simpler and looks like modern JSON APIs. The contact IDs are the Google profile IDs, and viewing photos doesn't require authentication. As a result it is now possible to provide an integrated abstraction over Google+ and Portable Contacts operations (same model class for Portable Contact entry and Google+ person) and perform cross-API operations (for example, list your contacts and for each contact list their activities).

                Unfortunately both Google+ API and Portable Contacts API are far from complete and both don't provide any write operations yet. As said above, I prefer to focus on the new JSON APIs and not GData. I'll look into the possibility of GoogleTemplate to expose access to Google's Java clients for GData API, to allow you to set up everything with Spring Social Google but still work with GData APIs.

                Comment


                • #53
                  Hi,

                  I'm trying to use this functionality in a Spring 3.0 environment.
                  At the moment I get some exceptions on the code in the jackson-mapper-asl-1.9.5.jar and jackson-core-asl-1.9.5.

                  org.springframework.web.util.NestedServletExceptio n: Handler processing failed; nested exception is java.lang.LinkageError: loader constraint violation: when resolving method "org.springframework.http.converter.json.MappingJa cksonHttpMessageConverter.setObjectMapper(Lorg/codehaus/jackson/map/ObjectMapperV" the class loader (instance of de/hybris/tomcat/HybrisWebappClassLoader60) of the current class, org/springframework/social/google/api/impl/GoogleTemplate, and the class loader (instance of de/hybris/bootstrap/loader/PlatformInPlaceClassLoader) for resolved class, org/springframework/http/converter/json/MappingJacksonHttpMessageConverter, have different Class objects for the type org/codehaus/jackson/map/ObjectMapper used in the signature
                  org.springframework.web.servlet.DispatcherServlet. doDispatch(DispatcherServlet.java:839)
                  org.springframework.web.servlet.DispatcherServlet. doService(DispatcherServlet.java:719)
                  org.springframework.web.servlet.FrameworkServlet.p rocessRequest(FrameworkServlet.java:644)
                  ...........
                  and

                  java.lang.LinkageError: loader constraint violation: when resolving method "org.springframework.http.converter.json.MappingJa cksonHttpMessageConverter.setObjectMapper(Lorg/codehaus/jackson/map/ObjectMapperV" the class loader (instance of de/hybris/tomcat/HybrisWebappClassLoader60) of the current class, org/springframework/social/google/api/impl/GoogleTemplate, and the class loader (instance of de/hybris/bootstrap/loader/PlatformInPlaceClassLoader) for resolved class, org/springframework/http/converter/json/MappingJacksonHttpMessageConverter, have different Class objects for the type org/codehaus/jackson/map/ObjectMapper used in the signature
                  org.springframework.social.google.api.impl.GoogleT emplate.getMessageConverters(GoogleTemplate.java:1 08)
                  org.springframework.social.oauth2.AbstractOAuth2Ap iBinding.<init>(AbstractOAuth2ApiBinding.java:61)
                  ..................
                  Can anyone tell me what needs to be done to get this functionality up and running in a Spring 3.0 environment?


                  Thank you.

                  Comment


                  • #54
                    How to access Google Contacts API

                    Is there any way to access contacts information using this?

                    Comment

                    Working...
                    X