1
votes

I am using the fbconnect module in my play application but I get the following error.

The file {module:fbconnect}/app/controllers/FBConnect.java could not be compiled. Error raised is : play.modules.fbconnect.FBConnectPlugin cannot be resolved

I downloaded the fbconnect from Here. Renamed the folder to fbconnect and put it in

C:/play/myproject/modules

In the dependencies.yml I put

require:
- play -> fbconnect 0.6

In C:/play/myproject/conf/application.config

# Facebook Connect
# ~~~~~
fbconnect.id=APP_ID
fbconnect.apiKey=API_KEY
fbconnect.secret=APP_SECRET
fbconnect.model=models.User
fbconnect.landUrl=/

What I am doing wrong. after downloading the fbconnect and making the required changes in dependencies.yml and application.conf. I run play dependencies as well.

Thanks in advance

2
just wondering - which version of play is this? If 1.+, any reason why you would prefer this over social secure? - ali haider
@ali haider what is social secure? - Zoha Ali Khan
if you're using play 1.+ and not 2.+, you could look into socialsecure (playframework.org/modules). I am not sure if socialsecure is available for play 2.0+. - ali haider
@ali haider I am using 1.something - Zoha Ali Khan
Is there any tutorial which explains how to use this module for implementing login with facebook for my site ? - Zoha Ali Khan

2 Answers

0
votes

If you plan on doing Facebook sign-in as well as other networks sign-in (like twitter or google), I suggest you pick an up-to-date library in Java, the problem with 1.x modules is that the method the networks used to communicate with their APIs are generaly outdated.

I wanted to do a Facebook and Google sign-in, and tried to use secure social for 1.2.4, the problem is Google now uses OAuth2 instead of first OAuth. I even tried to change the module using the source code from the play 2.0 scala securesocial, and "translate" it to java.

So I just picked a java library (wich are generaly uptodate), scribe ( https://github.com/fernandezpablo85/scribe-java ), and it worked perfectly fine.

What I exactly did :

  • Check scribe-java github page
  • Download the fork I wanted from the fork list
  • Build from Maven
  • Coded what I needed

Good luck with your app.

0
votes

The following URL provided more details on secure social (with play framework 1.0+):

http://www.playframework.org/modules/securesocial-0.2.4/home

If you are looking to work with the social graph and not just auth, I would recommend either restFB or batchFB.

Steps: For Setup: Either use:

play install socialsecure-0.2.4

or add to dependencies.yml file

require:
  -play -> securesocial 0.2.4

& then run

play deps

Add the route to the routes file:

*       /auth       module:securesocial

Add the following to whichever controller class that needs authentication:

@With( SecureSocial.class )
public class Application extends Controller {

Ensure that your provider e.g. twitter or facebook are in the provider list in the application.conf file. Also ensure that you have the correct key/ID & secret for your app (specified in the application.conf file). Once done, ensure that your references to securesocial are in place (if not, run play eclipsify or the appropriate command for whichever IDE you are using). Once done, launch the app and test facebook (or other provider link) - ensure that the facebook return URL is correctly specified in the facebook app (on facebook).

One can modify the main.html page etc as needed to ensure that you use the CSS/content/login display as needed.

If using groovy templates, you can add the following to your html view to display some user information:

 <h2><img src="${user.avatarUrl}" width="40px" height="40px"/> Welcome    ${user.displayName}</h2>

Hope it helps