Network/user/tutorials/facebook-authentication
From CubeiaWiki
User Service and Firebase Integration
This is a quick primer on how to utilize Facebook Connect to authenticate a user and migrate user data from FB to the user service. The tutorial also shows how to test the facebook integration using firebase and a flash client.
Prerequisites:
- The user service and firebase need to be set up by following User Service & Firebase tutorial.
Configure User Service
- You need a Facebook application that the user service can authorize users against. Either create a new facebook application or use the default http://www.facebook.com/apps/application.php?id=145490192136524 application.
- Add a user-service.properties file in a directory called user-service/ to you application containers classpath. The file should look something like this:
# Default facebook key user.service.migration.facebook.key=d84ca3ae7810403850837a375362ca59 # Facebook key for specific operator user.service.migration.facebook.key.operator.0=d84ca3ae7810403850837a375362ca59 # Default facebook secret user.service.migration.facebook.secret=1c49d6d2617bed3b26e2a8bdcc048e90 # Default facebook secret user.service.migration.facebook.secret.operator.0=1c49d6d2617bed3b26e2a8bdcc048e90 # true/false - Turn facebook migration adapter on/off user.service.migration.facebook.active=true # true/false - Turn facebook migration adapter on/off for a specific operator user.service.migration.facebook.active.operator.0=true
You have the option to add operator specific configuration by appending the text "operator.ID" to a key. You can ignore that for now, but just make sure you set the correct ..facebook.key and ..facebook.secret values to your facebook applications values and that the ..facebook.active key is set to "true". Remember that if you dont create your own facebook application, you can just copy paste this configuration.
Test
- Start Firebase by running the start script in $FIREBASE_HOME
- Start the User Service apllication
- Open the URL http://cubeia.org/docs/firebase/1.7.0-CE/firebase-ce-test-client/1.7.0.1/ in a browser and connect to your local firebase server.
- Click the "Switch to Facebook login" button and click again on the "Connect to Facebook" button. The browser will open a new tab to Facebook where you can login if you havent already.
- Now click on the "Click after you log into Facebook" button and if everything goes as planned you will be authorized by facebook and some basic data will be migrated from FB to your local user.
- Check out your newly migrated user in your database!

