Milos Zikic - Personal site, sharing thoughts about startups, products and engineering

Native Facebook SSO in Android

Android Facebook integration

Today mobile app without easy way to get inside is considered unfriendly. Users love to share the joy of using something nice with their friends and simply love to have to remember just one password. 

Facebook is a great SSO service and it is considered a "must have" feature. 

Fortunately it is easy to integrate it. There is Android Facebook SDK created by Facebook itself, but I want to draw your attention to Android Query library. It is a great asset for Android development. It contains all the little helpers that you might need during developing your super awesome apps. And of course you want to focus on getting it awesome, so AndroidQuery is a real thing to help you out. 

Apart from other things in the package there is a SSO capatibility and Facebook authentication is really easy (either through web, or native FB app). 

The process there is straight forward, and you have demos to help as well. What is not that clear is how to generate a key hash for Facebook native android app. Here is how it looks on Facebook developer page:
facebook key hash

This field will accept multiple hashes. So, for your developer certificate use following (use the password "android"): 

keytool -exportcert -alias androiddebugkey \
-keystore ~/.android/debug.keystore | openssl sha1 -binary \
| openssl enc -a -e


And for your production builds you can generate key hash by executing following over your p12 certificate


keytool -export -alias com.yourappname -storetype pkcs12 \
-keystore cert/certificate.p12 | openssl sha1 -binary \
| openssl enc -a -e


"com.yourappname" is your keyalias. You can find out this one by executing

keytool -list -storetype pkcs12 -keystore cert/certificate.p12 -v


Happy coding!

Share this post