Page 1 of 1

Unable to login with facebook

Posted: Tue Apr 02, 2013 2:18 am
by deepali
i had put the functionality of "sign in with facebook" and twitter ,
but when i click on login i got an error like

org.springframework.web.method.support.InvocableHandlerMethod.<init>(Lorg/springframework/web/method/HandlerMethod;)V

. How to solve this ?

Re: Unable to login with facebook

Posted: Tue Apr 02, 2013 10:06 am
by jfridye
Have you created and configured a Facebook application?
Have you configured your ecommerce application with the correct information from Facebook?
Here is an article we wrote on the subject:
Why Your Ecommerce Site Should Integrate with Spring Social - http://www.broadleafcommerce.com/post/w ... ing-social

If you could, please provide more information/context around the issue you are having, and we may be able to help you further.

Re: Unable to login with facebook

Posted: Thu Apr 04, 2013 4:47 am
by deepali
first of all that versioning error was solved but now i am unable to sign in with facebook (no error, no output)
yes i had created facebook application and provided client id and clientsecrect in developement.properties.
And i had follow that link but still i can't get any output

Re: Unable to login with facebook

Posted: Fri Apr 05, 2013 9:22 am
by jfridye
Could you provide us additional information to aide us in helping you? Any of the following would be helpful:
- stack trace / console output
- applicationContext-social.xml configuration
- Facebook Login template code
- screenshots

Thanks

Re: Unable to login with facebook

Posted: Mon Apr 08, 2013 5:36 am
by deepali
This is my applicationContext-social.xml file in site

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
   xsi:schemaLocation="http://www.springframework.org/schema/aop
       http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
     http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">

   <bean id="connectionFactoryLocator"
      class="org.springframework.social.connect.support.ConnectionFactoryRegistry">
      <property name="connectionFactories">
         <list>
            <bean
               class="org.springframework.social.facebook.connect.FacebookConnectionFactory">
               <constructor-arg value="${facebook.clientId}" />
               <constructor-arg value="${facebook.clientSecret}" />
            </bean><!-- <bean class="org.springframework.social.twitter.connect.TwitterConnectionFactory">
               <constructor-arg value="${twitter.consumerKey}" /> <constructor-arg value="${twitter.consumerSecret}"
               /> </bean> -->
         </list>
      </property>
   </bean>
   <!-- <bean id="usersConnectionRepository" class="org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository">
      <constructor-arg ref="webDS" /> <constructor-arg ref="connectionFactoryLocator"
      /> <constructor-arg ref="textEncryptor" /> <aop:scoped-proxy proxy-target-class="false"
      /> <property name="tablePrefix" value="BLC_"/> </bean> -->

   <bean id="xFacebookSaveDataServiceXml"
      class="com.mycompany.controller.account.FacebookSaveDataService" />

   <bean id="xatonConnectionSignUp" class="com.mycompany.controller.account.XatonConnectionSignUp">
      <property name="facebookSaveDataService" ref="xFacebookSaveDataServiceXml" />
   </bean>

   <bean id="usersConnectionRepository"
      class="org.springframework.social.connect.jdbc.JdbcUsersConnectionRepository">
      <constructor-arg ref="webDS" />
      <constructor-arg ref="connectionFactoryLocator" />
      <constructor-arg ref="textEncryptor" />
      <aop:scoped-proxy proxy-target-class="false" />
      <property name="tablePrefix" value="BLC_" />
      <property name="connectionSignUp" ref="xatonConnectionSignUp" />
   </bean>

   <bean id="connectionRepository" factory-method="createConnectionRepository"
      factory-bean="usersConnectionRepository" scope="request">
      <constructor-arg value="#{session.customer.username}" />
      <aop:scoped-proxy proxy-target-class="false" />
   </bean>

   <!-- Configure this to use the Broadleaf Runtime Environment properties
      file -->
   <bean id="textEncryptor" class="org.springframework.security.crypto.encrypt.Encryptors"
      factory-method="noOpText" />
</beans>


i have also created 2 classes in
/site/src/main/java/com/mycompany/controller/account/FacebookSaveDataService.java
and
/site/src/main/java/com/mycompany/controller/account/XatonConnectionSignUp.java

code of XatonConnectionSignUp.java is as below

Code: Select all

package com.mycompany.controller.account;

import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionSignUp;

public class XatonConnectionSignUp implements ConnectionSignUp{

   private FacebookSaveDataService facebookSaveDataService;
   @Override
   public String execute(final Connection<?> connection) {

      return getFacebookSaveDataService().saveOrUpdate(connection);
   }
   public void setFacebookSaveDataService(FacebookSaveDataService facebookSaveDataService) {
      this.facebookSaveDataService = facebookSaveDataService;
   }
   public FacebookSaveDataService getFacebookSaveDataService() {
      return facebookSaveDataService;
   }
}



and code of FacebookSaveDataService.java is as below

Code: Select all

package com.mycompany.controller.account;

import javax.annotation.Resource;

import org.broadleafcommerce.profile.core.domain.Customer;
import org.broadleafcommerce.profile.core.service.CustomerService;
import org.springframework.social.connect.Connection;
import org.springframework.social.facebook.api.Facebook;

public class FacebookSaveDataService {
   @Resource(name="blCustomerService")
   private CustomerService customerService;

   @SuppressWarnings("null")
   public String saveOrUpdate(Connection<?> connection)
   {
      Customer customerInDb = customerService.readCustomerByEmail(connection.fetchUserProfile().getEmail());
System.out.println(customerInDb);
      if(customerInDb != null)
      {

         customerInDb.setUsername(connection.fetchUserProfile().getEmail());
         customerInDb.setFirstName(connection.fetchUserProfile().getFirstName());
         customerInDb.setLastName(connection.fetchUserProfile().getLastName());


         // get more data from facebook
         Facebook facebook = (Facebook) connection.getApi();

         customerService.saveCustomer(customerInDb);

         return connection.fetchUserProfile().getEmail();
      }
      else
      {
         Customer customer = null;
         customer.setEmailAddress(connection.fetchUserProfile().getEmail());
         customer.setUsername(connection.fetchUserProfile().getEmail());
         customer.setFirstName(connection.fetchUserProfile().getFirstName());
         customer.setLastName(connection.fetchUserProfile().getLastName());
         customer.setId(customerService.findNextCustomerId());
         customer.setPassword(Double.toString(Math.random()));
         // get more data from facebook
         Facebook facebook = (Facebook) connection.getApi();

         customerService.registerCustomer(customer, customer.getPassword(), customer.getPassword());

         return customer.getEmailAddress();
      }
   }
}


and my development.properties file in site is as follow in which i also mentioned facebook client id and client secret as per my created facebook application in developer.facebook.com

Code: Select all

# These settings override and append settings in:

# common-shared.properties
# development-shared.properties
# common.properties
# Please see common-shared.properties for more information on how the properties files work
blPU.hibernate.hbm2ddl.auto=update   
blPU.hibernate.hbm2ddl.import_files=/sql/load_admin_security.sql,\
                                    /sql/load_admin_users.sql,\
                                    /sql/load_code_tables.sql,\
                                    /sql/load_table_sequences.sql,\
                                    /sql/load_content_structure.sql,\
                                    /sql/load_catalog_data.sql,\
                                    /sql/load_content_data.sql

blCMSStorage.hibernate.hbm2ddl.auto=update

blSecurePU.hibernate.hbm2ddl.auto=update
#Spring Social
facebook.clientId=155533324613225
facebook.clientSecret=6c9e4461edf9a63c88bd5015f00df055

application.url=http://127.0.0.1:8080


and in login.html in site i had also pass hidden parameters as follow

Code: Select all

<div id="account">
<div style="display: none;" th:fragment="title" th:inline="text">Login
- Broadleaf Demo - Heat Clinic</div>

<div id="login">
<h3><span th:text="#{login.loginToAccount}">Login to Your
Account</span></h3>
<p><span th:text="#{login.alreadyMember}">Already a member?
Sign in using the form below</span>.</p>

<span class="error" th:if="${param.error}">
<p><span th:text="#{login.noMatchTryAgain}">The e-mail
address and/or password entered do not match our records. Please try
again</span></p>
</span>

<div class="clearfix">
<blc:form th:action="@{/login_post.htm}"
   method="post">
   <input type="hidden" name="successUrl" th:if="${successUrl}"
      th:value="${successUrl}" />

   <div class="form50"><label for="j_username"><span
      th:text="#{login.email}">Email</span></label> <input type="email"
      name="j_username"
      th:class="${param.error} ? 'field50 fieldError' : 'field50'" /></div>

   <div class="form50"><label for="j_password"><span
      th:text="#{login.password}">Password</span></label> <input type="password"
      name="j_password"
      th:class="${param.error} ? 'field50 fieldError' : 'field50'" /></div>

   <div class="login_register"><input class="login_button big red"
      type="submit" th:value="#{login.login}" /></div>

   <div class="login_register_alt_links"><a class="account"
      th:href="@{/register}"><span th:text="#{login.register}">Register</span></a>
   <br />
   <a class="account" th:href="@{/login/forgotPassword2}"><span
      th:text="#{login.forgotPassword}">Forgot Password</span></a></div>
</blc:form>

<h4>OR</h4>
<!--<blc:form th:action="@{/signin/twitter}" method="POST">
   <button type="submit"><img
      th:src="@{/img/social/sign-in-with-twitter-l-sm.png}" /></button>
</blc:form> <br />--> <blc:form th:action="@{/signin/facebook}"
   method="POST">

   <input type="hidden"
      value="email,user_about_me,user_activities,user_birthday,user_education_history,user_hometown,user_location,user_relationships,user_website,friends_birthday"
      name="scope" />
   <button type="submit"  clarss="btn_fb"><img
      th:src="@{/img/social/facebook_16.png}" /> &nbsp; Sign in with
   Facebook</button>
</blc:form></div>
</div>
</div>

Re: Unable to login with facebook

Posted: Sat Jul 13, 2013 10:29 am
by t0mkaka
I have the same problem.

Any answers

Re: Unable to login with facebook

Posted: Mon Jul 15, 2013 9:21 am
by Paulius
When I had this problem, I updated main pom.xml file with additional repository and that solved my problem

Code: Select all

<repository>
            <id>spring.social</id>
            <name>spring</name>
            <url>http://maven.springframework.org/milestone/</url>
       </repository>