Announcement Announcement Module
Collapse
No announcement yet.
Spring Security + Spring Social + Filters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    After looking at the latest github code, perhaps getting access to the connection attribute of ProviderSigninAttempt is what I need to fit my requirements.

    Comment


    • #17
      Ok, now we're getting somewhere. What exact "provider user" fields do you need to obtain to populate your signup form? Would you expect to send these field values through as parameters in a redirect to the signup form, or store them in session scope through the signup process?

      Comment


      • #18
        For the moment I need the providerAccountId/screenname and profile picture url. But I suggest that you provide a way to get the full api template for more advanced usage (in this case it's probably up to the developper to transtype what you return into to the native template object)

        I'm not sure what is the best way to make this available to the developpers.
        Storing it in the session and having a function in https://github.com/SpringSource/spri...gnInUtils.java may be the easiest way.

        Using request parameters is not my favorite option because some developpers might innocently trust untrusted input.

        Comment


        • #19
          Well, take a look at the ServiceProviderConnection interface and the ServiceProviderUser object returned from getUser() and let me know if that meets your needs. If you need the specific provider API, you can call getServiceApi() however you'd be tying yourself to a specific provider then. The ServiceProviderConnection is designed to provide the uniform interface and that's what I want to make sure has the right balance of "common properties".

          Keith

          Comment


          • #20
            That seems fine as soon as I can get an instance of this connection object.

            Is it acceptable to provide an accessor to

            private final ServiceProviderConnection<?> connection; in ProviderSignInAttempt (https://github.com/SpringSource/spri...InAttempt.java)

            In this case I agree that developpers should use the getUser() method for all common attributes.

            Comment


            • #21
              Yes I'll make sure this is taken care of for M3. Thanks for the feedback, that's the kind of stuff we need.

              Comment


              • #22
                Ok. I added a getUser() method to ProviderSignInAttempt exposing a ServiceProviderUser model. We can also consider adding more user fields to that model if there is demand.

                Comment


                • #23
                  Thanks

                  I've noticed the function in the latest snaphot.

                  Code:
                  	/**
                  	 * Get the profile of the provider user that attempted to sign-in.
                  	 * Profile fields can be used to pre-populate a local user registration/signup form.
                  	 */
                  	public ServiceProviderUserProfile getUserProfile() {
                  		return connection.fetchUserProfile();
                  	}
                  I would also love a getConnection()

                  Finally, can I consider the snapshot API stable enough to migrate my code now ?

                  Comment


                  • #24
                    Take a look at what's there now. I see what you mean about exposing the ServiceProviderConnection but take a look and let me know if the new ServiceProviderUserProfile meets your needs (see ProviderSignInUtils for easy access to it).

                    The API is settling down, yes.

                    Comment


                    • #25
                      I went ahead and made an update that allows the entire ServiceProviderConnection object to be accessed as you suggested. This is reflected in the latest snapshot available now. The Greenhouse reference app has also been updated to use this feature (you can see it there by cloning the code, running locally, and attempting to Sign in with Facebook).

                      Keith

                      Comment


                      • #26
                        Great.

                        The snaphot version I was using returned an empty profile but it seems you have fixed it today.

                        public ServiceProviderUserProfile fetchUserProfile() {
                        return new ServiceProviderUserProfile(null, null, null, null, null);
                        }

                        I've also noticed an SQL error (with MySQL) because of JdbcServiceProviderConnectionRepository.addConnect ion
                        Here is the error messae details : 1093 - You can't specify target table 'ServiceProviderConnection' for update in FROM clause

                        Since I'm using roo/JPA in my project I will implement a JPA based connection repository that will fix this issue for me.

                        Comment


                        • #27
                          Shad,

                          Any idea what's going on with that MySQL failure on addConnection? I turned MYSQL Compatibility mode on in our unit tests against H2 and they all pass. Wondering what's going on.

                          Keith

                          Comment


                          • #28
                            Hi Keith,

                            First of all, thanks for the code change. It works like a charm by using the new function
                            Code:
                            ProviderUserSignInUtils.getConnection(request).fetchUserProfile()
                            ; in my SignupController (note that twitter does not give access to the email address)

                            Here is the jdbc error details :

                            org.springframework.jdbc.UncategorizedSQLException : PreparedStatementCallback; uncategorized SQLException for SQL [insert into ServiceProviderConnection (localUserId, providerId, providerUserId, rank, profileName, profileUrl, profilePictureUrl, accessToken, secret, refreshToken, expireTime) values (?, ?, ?, (select ifnull(max(rank) + 1, 1) from ServiceProviderConnection where localUserId = ? and providerId = ?), ?, ?, ?, ?, ?, ?, ?)]; SQL state [HY000]; error code [1093]; You can't specify target table 'ServiceProviderConnection' for update in FROM clause; nested exception is java.sql.SQLException: You can't specify target table 'ServiceProviderConnection' for update in FROM clause

                            It seems that you can't use a subquery select on the insert target table.

                            http://dev.mysql.com/doc/refman/5.0/...ry-errors.html

                            Comment


                            • #29
                              Shad,
                              Thanks for the information. I broke the subquery out into its own query and made the entire method @Transactional. Let me know if this works OK on MySQL (it should and our local tests pass).

                              Thanks again,

                              Keith

                              Comment


                              • #30
                                hi guys, can you please put all things together in a sample for sharing sake.

                                Comment

                                Working...
                                X