Announcement Announcement Module
Collapse
No announcement yet.
connect to facebook using popup without the need of post request Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • connect to facebook using popup without the need of post request

    Hi,

    I see from the javadoc that I can connect to facebook using post method to connect/facebook.
    I would like to be able to connect to facebook by opening popup window to facebook auth url instead of replacing the current window. Is it possible with spring social? I could not find any example/post for that.

    Thanks in advance

  • #2
    Sign in with popup flow

    I vote for this, for many applications the desired sign-in flow requires opening a popup window for the sign-in which closes itself after successful signin.
    Anyone has suggestions?

    Comment


    • #3
      Have you seen the Spring Social Popup sample at https://github.com/SpringSource/spri...g-social-popup ? Does it show what you're looking for? If not, how does it differ from what you're trying to do?

      Comment


      • #4
        Right, I somehow missed that, sorry.
        Nice trick, I expected the solution to include a GET interface but I guess that isn't needed.
        Guy

        Comment


        • #5
          Originally posted by habuma View Post
          Have you seen the Spring Social Popup sample at https://github.com/SpringSource/spri...g-social-popup ? Does it show what you're looking for? If not, how does it differ from what you're trying to do?
          Hi Craig,
          It does not seem to work on signin page. Is there anything special that need to be done in order for the pop up to show the face book sign in on unauthenticated page. Here is what is happening for me. Pop up opens and closes in few seconds.

          here is jsp snippet
          <form action="/signin/facebook" method="POST" class="connectForm">

          <button class="connectButton" type="submit"><img src="<c:url value="/resources/social/facebook/sign-in-with-facebook.png" />"/></button>

          </form>


          **********************Java script snippet***************
          <script>
          $(document).ready(function() {
          $(".connectButton").click(function(event){
          event.preventDefault();
          window.open("", "connectWindow", "width=600,height=400");
          var cTP = $(event.currentTarget).parent();
          cTP[0].setAttribute("target", "connectWindow");
          cTP[0].submit();
          });
          });
          </script>

          Comment


          • #6
            How can I enable popup during Sigin. I tried the following but still am missing something somewhere. Any help would be appreciated. Here are steps
            1. Modified the providerSignInController to add an interceptor
            @Bean
            public ProviderSignInController providerSignInController(RequestCache requestCache) {
            ProviderSignInController signInController = new ProviderSignInController(connectionFactoryLocator, usersConnectionRepository, new SimpleSignInAdapter(requestCache));

            signInController.addSignInInterceptor(new PopupDialogSignInInterceptor() );
            return signInController ;
            }

            2. Created a Signin Interceptor and added the display parameter for Facebook.
            public class PopupDialogSignInInterceptor implements
            ProviderSignInInterceptor<Facebook> {



            @Override
            public void postSignIn(Connection<Facebook> connection, WebRequest request) {
            // TODO Auto-generated method stub

            }

            @Override
            public void preSignIn(ConnectionFactory<Facebook> connectionFactory,
            MultiValueMap<String, String> parameters, WebRequest request) {
            parameters.set("display", "popup");

            }

            }

            Let me know if I am missing something in the equation.

            Comment


            • #7
              Thanks for pointing out the problems with the popup example. Admittedly, it doesn't get as much attention as the showcase samples, so it seems that it had fallen into a state of disrepair. I've corrected it, tested it, and pushed the fixes to GitHub. Try it now and see if it works for you. (I know it worked for me just moments ago.)

              I'll followup in a separate message to describe how this works.

              Comment


              • #8
                Okay, so the essential "trick" here is that I have some jQuery code that intercepts the click on any button whose class is ".connect". It then rewires the DOM around that button's form to open in a popup dialog. Upon return after redirect from the provider, it detects that the popup window is not the main window (e.g., "if (window.opener)") and forces the original connection window to reload before it closes the popup.

                It's kinda hacky, I admit. There's possibly a better way of doing it. At very least, perhaps it could trigger off of the submit of any form whose class is ".connect" instead of the button...that way I don't have to lookup the button's parent to get the form. And, I suppose it's not really necessary to decorate the button (or form) on click (or submit)...I could do that when the page is loaded. And there's still probably better ways of accomplishing this. I'm a bit more Javascript-savvy now than I was a couple of years ago when this sample was first written. :-)

                As for how to do this with signin...I suspect the process would be quite similar, but I've not tried it yet. Let me give it a shot and I'll follow up with what I find.

                Comment


                • #9
                  Also...I see what you're trying to do by setting the display parameter to popup. That's good, albeit Facebook-specific. You probably noticed I did that for the connect scenario, too. Doing that does not make it a popup. It just tells Facebook to style the connect/signin page so that it looks better in a popup. It's still up to you to make the popup happen, which is what the Javascript code I mentioned before does.

                  Comment


                  • #10
                    Thanks for the reply Craig.... I have to thank for all the contribution on the social project....especially with the samples it is of huge help..... Not sure of the time frame but it would be of great help if you can do a pop up implementation using the /sigin on the show case example for one of the social sites.......No matter what I do....something with the /Signin it does not like and am having fun with it since couple of days now....and i even tried the same javascript as what you have with the popup...just to get it to work.... Any insight will be appreciated....

                    Comment

                    Working...
                    X