Quickly Enable Social Logins with JanRain Engage
AUGUST 31, 2010
ReadWriteHack ReadWriteWeb ReadWriteStart ReadWriteBiz ReadWriteEnterprise ReadWriteCloud ReadWriteHack International ReadWriteBrazil ReadWriteChina ReadWriteFrance ReadWriteSpain ReadWriteHack Home Archives More Articles & Blogs RSS Twitter Facebook How To: Quickly Enable Social Logins with JanRain Engage By Ben Barden / August 31, 2010 8:40 AM / Loading Comments Tweet This post is part of our ReadWriteHack channel, which is a resource and guide for developers. The channel is sponsored by the Intel AppUp Developer Program. JanRain Engage provides a convenient way to enable social logins on a site via a single API. This includes support for Facebook, Google, Twitter, LinkedIn and over a dozen additional services. Implementing JanRain Engage on your site is a lot less work than implementing each login provider one by one. Also, as any changes to each login will be handled by JanRain, you wont have to keep updating your authentication code if changes are made by the login provider. Creating Your Application Start by going to JanRain Engage and signing in. Of course, youll need to use a social login to get into the site. If you havent seen the sign-in interface before, this is a good opportunity to have a look at it. Well come back to this in a moment. Once youve signed in, click the "Create Application" link from the drop down list at the top. By default, youll be prompted to purchase a "Plus" application. Look for the link that says "Create a basic application" - this will allow you to try the service for free. (Note: You can use JanRain Engage for free if you wish. You can upgrade to the Plus version at a later date if you need some of the enhanced features.) Simply type the name of your application and click the "Create Application" button. Then click "Get Started" and you can start deploying the widget. You can return to this stage of the process by clicking the "Sign-in" link from your applications home page. Adding the Widget On the "Get the Widget" screen, youll be asked for your token URL. For the moment, just enter the URL of your home page and click Next. This can be changed later. Now click the "Generate Code" button. Youll be given two code snippets that look something like this: This code should go immediately before the tag. The second snippet is: This is the Sign In link. "yoursite" will be replaced with the name of your site. Getting Your API Key In the next step, "Handle Tokens", youll be given your API key. Copy the key, as youll need it in a moment. Choosing Your Login Providers Many of the popular login providers require configuration. These are shown with a gear icon. For now, remove the default providers and add one or two login providers that dont require configuration. Make sure you choose at least one provider where you have an account. We can come back and add some more later. A Helpful Login Class Some code examples are provided by JanRain Engage. These are good for getting started. However, they will need to be changed if you need to access any other API calls in the future. With this in mind, I created a class that might be useful. Dont forget to complete the class - look for the @todo tags. Once youve included the file in your project, just include the following code on the page that youre using to process login requests: I usually include the code in the bootstrap file of my project, so you can check if a user has just logged in from any page of your site. Once the code is on your site, youll need to test it. A Very Simple Example Ive set up a site where you can try out the Twitter login. The site doesnt do much except allowing you to log in and click a button. Its a good idea to set up a sandbox such as this so you can try out the functionality before using it on a real site. Let us know in the comments if youve used JanRain Engage for your site or if theres anything else youd like to know about it. See Also PHP5 Alternatives for Red Hat Enterprise Linux A Quick Look at ORM for PHP Getting Up and Running Faster with zfKit Hack of the Day: Use PHPs List Function to Quickly Transform Arrays to Variables Tweet « Prior Post Next Post » Posted in How-To and tagged with login , openid , php , social Comment Subscribe E-mail This Print This Digg Share Hi Christian - Ive replied… Hi Christian - Ive replied to your email. To summarise - getByIdentifier should get the users identifier from your Users table, if the user has logged in before; createUser should add a new user to the database, if its the first time they have logged on. These both need to go in a class called models_user_User - your error suggests you havent created this class yet. Posted on 9 September 2010 | 3:27 pm Thanks Andre - Ive updated… Thanks Andre - Ive updated the post. Posted on 9 September 2010 | 3:25 pm Hi Ben. Your article is the… Hi Ben. Your article is the only useful information Ive found about Engage but one thing I dont get is, what methods do you say we have to write? (in the @todo tags) I dont get what are those methods supposed to do. I tried your class just changing my API Key and I got this error: Fatal error: Class models_user_User not found in. However, when I do an echo of the $rpxProfile[displayName], I get a correct output. Is this error related to what Im supposed to write? I would really appreciate if you can give me a hand with that. Thank you so much for the help and the tutorial! (Ill definitely credit you in my website) Posted on 8 September 2010 | 7:33 pm Thats add it right before… Thats add it right before not :) Posted on 31 August 2010 | 8:31 pm Sponsored by Why AppUp? A Quick Review of the AppUp Model From the Atom Developer Program Blog The Game Creators show off FREE method for creating AppUp MSI AppUp Round-Up: Hot Apps from IDF Intel AppUp developer Program: App Submission Issues Now resolved Watch LIVE from AppUp Elements in San Francisco The AppUp Elements 2010 Liveblog More from the Atom Developer Blog » Articles & Blogs Conceptualizing Your Ported Application on the Netbook Platform "What will my application be like on the netbook?" This is the question posed by iPhone developers around the world as they begin porting to the Intel® AtomTM SDK. When porting an application from one platform to another, the first item we as developers tend to think about is the programming language. Let us set that aspect aside and have a look at the hardware differences and how they affect the overall user experience. While a direct port of your applications features and user interface would be simple, a bit of due diligence up front may necessitate minor changes that will ensure what you end up with at the end of the porting process is what you had envisioned. More articles & blogs » Popular 6 Tips for Building Coherent Site Navigation September 17, 2010 / Loading Comments Interview with Richard Clark September 10, 2010 / Loading Comments Twisted Firestarter: Windows Phone 7 for Developers September 13, 2010 / Loading Comments Day 2: Intel AppUp Elements 2010 September 16, 2010 / Loading Comments Broadband Graphing with Ease September 20, 2010 / Loading Comments POPULAR TAGS php appup intel unconference api linux logging network statistics testing utilities ab-testing abstraction agents array auditing bash bigdata browsersize buzz caching centos class cloud cloudkick command line community conference css database developers doctrine engagement explode eyeballs facebookplaces flot forms framework geo geolocation googlereader graph growl id ieyenet infochimps interview jquery lbs Home | Features | Trends | Best of RWW | Archives ReadWriteWeb | Startups | Small Business | Enterprise | Cloud Computing | Developers About | Subscribe | Contact | Advertise © 2003-2010 ReadWriteWeb );//]]>. Tags: socalcto.