Results 1 to 8 of 8

Thread: spring-social-quickstart example works only for "Spring Social Quickstart"?

  1. #1
    Join Date
    Jun 2011
    Posts
    5

    Default spring-social-quickstart example works only for "Spring Social Quickstart"?

    Yes, I'm desperate but anxious to make working my facebook application with spring social, great framework (by the way, thank you a lot guys).

    Actually, my frustration came from that even I succeeded to make functioning the original
    spring-social-quickstart example, means with the original:
    facebook.clientId=a4108ecf36b5c73533e934909a623278
    facebook.clientSecret=b767a02bf8b36f92695ee165f88cadb5, from the
    application.properties file, changing the parameters, above, with mine (pointing my facebook application:

    facebook.clientId=<App ID value of my facebook application, from application settings>
    facebook.clientSecret=<App Secret value value of my facebook application, from application settings>

    I received this error:
    Code:
    GRAVE: Servlet.service() for servlet [appServlet] in context with path [/spring-social-quickstart] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: userId cannot be null] with root cause
    java.lang.IllegalArgumentException: userId cannot be null
    	at org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository.createConnectionRepository(JdbcUsersConnectionRepository.java:115)
    	at org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository.findUserIdWithConnection(JdbcUsersConnectionRepository.java:89)
    	at org.springframework.social.connect.web.ProviderSignInController.handleSignIn(ProviderSignInController.java:156)
    	at org.springframework.social.connect.web.ProviderSignInController.oauth2Callback(ProviderSignInController.java:150)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    after a correct facebook sigin.

    Could you please help me with some hints?

    Thx

  2. #2
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    Your ConnectionSignUp implementation is returning null and that's not allowed at the moment...

    I would ask yourself what you want to happen if no local user profile could be mapped from the Facebook user on a Sign in with Facebook attempt. ConnectionSignUp is designed to create a local user profile from the Facebook connection without manual user intervention. This is an optional thing. If you don't configure a ConnectionSignUp command, the user will be redirected to a sign-up form where they should be asked to complete their profile (which may be auto-filled in from Connection properties). The spring-social-quickstart just shows a dummy SimpleConnectionSignUp implementation that treats your Facebook user name as the local user id. If you're using this implementation as-is, perhaps the username field for the Facebook profile you're testing against is null?

    Keith
    Keith Donald
    Core Spring Development Team

  3. #3
    Join Date
    Jun 2011
    Posts
    5

    Default

    Thank you very much for your quick reply.
    Now I completed my facebook username (http://www.facebook.com/username/) and the quickstart social example starts to work fine.
    After that, I tried with another facebook profile(my friend one, for instance) and obviously I received the same error above (userid could not be null) and I'm wonder if it is so complicate that instead I received an error, the quickstart, to redirect to another page (/registerFBuser, for instance) asking the one, wants to play my "quick" application, to register their FB user name before using one(the application), instead of receiving an unfriendly error.

    What about skiping out even that step (asking application future beneficiary to create a FB username)? It's their any chance to avoid even this one?

    Thank you again.

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    We should definitely change the quickstart not to depend on the Facebook username field, which is an optional profile field.

    Keith
    Keith Donald
    Core Spring Development Team

  5. #5
    Join Date
    Jun 2011
    Posts
    5

    Default

    Yep, I looking forward for the next release may be something similar to this facebaook pyton sample(http://developers.facebook.com/docs/samples/canvas/) .

    In any case thx a lot for your help and support. I'm really appreciate and I'm trying to promote your work.

  6. #6
    Join Date
    Sep 2009
    Posts
    3

    Default

    Sorry to resurrect an old thread, but I've come across the same issue.

    The docs relating to ConnectionSignUp say:

    If execute() returns null, then it indicates that the user could not be implicitly signed up. In that case, ProviderSignInController's explicit sign up flow will be in effect and the browser will be redirected to the sign up form.
    Yet you say:

    Quote Originally Posted by Keith Donald View Post
    Your ConnectionSignUp implementation is returning null and that's not allowed at the moment...
    Is the code going change to allow returning null or are the docs out of date? Or have I completely missed something?

    Looking into the code, to be compliant with the docs it seems the findUserIdsWithConnection in JdbcUsersConnectionRepository needs to be altered to do this sort of thing:

    Code:
        public List<String> findUserIdsWithConnection(Connection<?> connection) {
            ConnectionKey key = connection.getKey();
            List<String> localUserIds = jdbcTemplate.queryForList("select userId from " + tablePrefix + "UserConnection where providerId = ? and providerUserId = ?", String.class, key.getProviderId(), key.getProviderUserId());        
            if (localUserIds.size() == 0) {
                if (connectionSignUp != null) {
                    String newUserId = connectionSignUp.execute(connection);
    
    
                    // START EDIT
                    if(newUserId == null) {
                        return Collections.emptyList();
                    }
                    // END EDIT
                    
                    createConnectionRepository(newUserId).addConnection(connection);
                    return Arrays.asList(newUserId);
                }
            }
            return localUserIds;
        }
    Thanks in advance.

  7. #7
    Join Date
    Aug 2004
    Posts
    1,070

    Default

    An update on this: https://jira.springsource.org/browse/SOCIAL-254 captures the issue described in this thread. And, as I've commented on that issue, the null case described in the documentation existed in earlier iterations of the implicit signup work, but no longer makes sense given the current implementation of implicit signup. I believe that the bug described is a documentation bug and that the documentation should be updated to reflect that the returned user ID cannot be null.

    Unless a compelling case is made to handle the null user ID case, I intend to fix this by updating the documentation.
    Craig Walls
    Spring Social Project Lead

  8. #8
    Join Date
    Nov 2011
    Location
    São Paulo, Brazil
    Posts
    6

    Default Newbieee

    I'm totally newbie in Spring Social and I'm in trouble.

    I have downloaded from GitHub (https://github.com/SpringSource/spring-social-samples). But I'm not successful in import it in Eclipse IDE. Any suggestion? I lost a lot of time in it.

    Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •