Announcement Announcement Module
Collapse
No announcement yet.
Spring social Facebook OAuthException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring social Facebook OAuthException

    We just launched a website with spring social but I found that on one computer (macbook pro/Safari) it gives an error.

    Code:
    {
       "error": {
          "message": "Invalid redirect_uri: Given URL is not allowed by the Application configuration.",
          "type": "OAuthException",
          "code": 191
       }
    }
    This is the url that it fails on
    Code:
    https://graph.facebook.com/oauth/authorize?client_id=[MY_CLIENT_ID]&response_type=code&redirect_uri=http%3A%2F%2F[MY_DOMAIN].com%2Fsignin%2Ffacebook&scope=publish_stream%2Cuser_photos%2Coffline_access
    I tried some other computers (Macbook Air/Safari & Firefox, Windows/IE) and it works fine. I also tried copy-pasting this url into another computer and it works fine.

    Has anyone seen this issue? It could be machine or browser specific.

    I am using spring social 1.0.2.RELEASE. Is it worth updating it to a later version?

    All feedback is really appreciated as we are not sure how big this problem is.

  • #2
    I can't describe in detail what's going on here because I don't know what domain you're on or how you've configured your application in Facebook. However...This error simply means that you've configured the Site URL in Facebook with one URL, but the redirect_uri parameter isn't based on that Site URL.

    For example, if your Site URL is "http://somedomain.com/mysocialapp", then you can use any redirect_uri that starts with "http://somedomain.com/mysocialapp". But if your redirect_uri is something different, such as "http://someotherdomain.com/mysocialapp", then you're going to get that error.

    The redirect_uri is determined automatically by Spring Social from the request going into ConnectController/ProviderSignInController. Under some circumstances, though, that may not work as expected. In those cases, you can explicitly configure the applicationUrl property on ConnectController to tell it what the base URL for your application should be.

    Comment


    • #3
      Yup i figured it out shortly after I posted. I had a Facebook app configured for my dev instance so the site url was localhost .. I created another one for my actual website. I didn't specify the domain on the latter and the former didn't need it. The strange thing is it was consistently working on some machines (macbook air with safari|firefox, win with IE) and not working with one (macbook pro with safari).

      Comment


      • #4
        'applicationUrl' property is not available in Spring social 1.0.2 .

        <bean id="connectionFactoryLocator" class="org.springframework.social.connect.support. ConnectionFactoryRegistry">
        <property name="connectionFactories">
        <list>
        <bean class="com.blimp.social.showcase.twitter.connect.T witterConnectionFactory">
        <constructor-arg value="${twitter.consumerKey}" />
        <constructor-arg value="${twitter.consumerSecret}" />
        <property name="applicationUrl" value="${application.url}" />

        </bean>
        </list>
        </property>
        <aop:scoped-proxy proxy-target-class="false" />
        </bean>

        In which class i need set applicationUrl in spring social 1.0.2?

        Comment


        • #5
          It is available in 1.0.2, but not on TwitterConnectionFactory. It was (and still is) on ConnectController and ProviderSignInController.

          Comment


          • #6
            Thanks I configured ConnectController but i get following error in Tomcat log

            SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListe ner
            org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'org.springframework.social.connect.web.ConnectCon troller#0' defined in ServletContext resource [/WEB-INF/spring/social.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.social.connect.web.ConnectCont roller]: No default constructor found; nested exception is java.lang.NoSuchMethodException: org.springframework.social.connect.web.ConnectCont roller.<init>()
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.instantiateBean(Abstrac tAutowireCapableBeanFactory.java:965)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBeanInstance(Abst ractAutowireCapableBeanFactory.java:911)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.doCreateBean(AbstractAu towireCapableBeanFactory.java:485)
            at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:456)
            at org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 93)
            at org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:222)
            at org.springframework.beans.factory.support.Abstract BeanFactory.doGetBean(AbstractBeanFactory.java:290 )
            at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:192)


            My Configuration as below

            <bean class="org.springframework.social.connect.web.Conn ectController">
            <!-- relies on by-type autowiring for the constructor-args -->
            <property name="applicationUrl" value="${application.url}" />
            </bean>

            <bean id="connectionFactoryLocator" class="org.springframework.social.connect.support. ConnectionFactoryRegistry">
            <property name="connectionFactories">
            <list>
            <bean class="com.blimp.social.showcase.twitter.connect.T witterConnectionFactory">
            <constructor-arg value="${twitter.consumerKey}" />
            <constructor-arg value="${twitter.consumerSecret}" />
            </bean>
            </list>
            </property>
            <aop:scoped-proxy proxy-target-class="false" />
            </bean>

            My requirement is this : I update spring-social-twitter4j sample to login to twitter/facebook once authorized it should need redirect to my home page(/home).

            Comment


            • #7
              You get that error because ConnectController doesn't have a default constructor. It must be constructed with a ConnectionFactoryLocator and a ConnectionRepository. I see that you've configured a ConnectionFactoryLocator, so you're half-way there.

              Although it's configured in Spring's Java-based configuration style (instead of XML like what you're doing), I recommend you have a look at the Spring Social Showcase (https://github.com/SpringSource/spri...ocial-showcase) to see how all of the pieces come together. Specifically, look at SocialConfig.java to see the Spring Social-specific configuration.

              Comment

              Working...
              X