Implementing Social Media Logins

Jeroen Steenbeeke  
This new site (currently) has three different ways to log in:

  • Twitter
  • Facebook
  • Google+

Originally, the site only supported Twitter, but when I gave the first few people a demo they suggested supporting other social media sites as well. My experiences with the various login methods have been mixed.

Twitter was the easiest. I've written half a dozen or so "log in using Twitter" procedures for various personal projects, so this was mostly copy/paste and using the Twitter4J API.

I am not aware of any Facebook libraries for Java that have the same level of maturity as Twitter4J, though considering the fact that I had a working implementation in another project, I didn't look very hard. It was mostly copy/paste with a few minor tweaks to get the info I needed.

Boy. Google+ was really hard to get to work. Google has comprehensive library support for its various APIs, so you'd think this would be pretty easy. The login flow resembles the one used by Facebook and Twitter (they're essentially all OAuth implementations). But working with the API is the equivalent of opening the puzzlebox that summons the Cenobites, or mud-wrestling with a Xenomorph.

Fortunately, I had an example to work with: a "login using Youtube" thingy I had written for a pet project. It's slightly less complicated than Google+, but gave me enough info to finish it without eating too much of my free time.

And there you have it! Three different ways to log in. Any others you think I should add? Github perhaps? Maybe (not sure if that's even possible)?


Hielke  Hielke
Posted 9/21/14 7:08 PM
(After clicking your login to comment link and logging in I end up at some odd page instead of right here.)

Try using org.scribe. We use it at Digdag and it had apis for all major sites. No hassle.

Jeroen Steenbeeke  Jeroen Steenbeeke
Posted 9/21/14 10:12 PM
Yeah you probably ended up in Recent Discussions. I'll see if I can figure out a way to redirect you to the page you clicked login from (if relevant). Shouldn't be too hard, can probably abuse the internal session for it :-P

As for org.scribe, I took a quick look at it, and it seems to be limited to just logging in. This would have been fine for Facebook and Twitter, but wouldn't have helped much with Google+, as all the necessary data (profile picture and such) still requires additional REST calls.

The most likely candidate for additional login method, at this point, is And I might add Github just for fun.