Android Account Kit Integration (Password free login)

Nobody is really fond of remembering passwords because at some point in our life we tend to mix them and due to security reasons we are unlikely to use same passwords everywhere. So what can be a better way of keeping the account safe as well as hassle-free from passwords? Facebook has a solution for that, Account Kit is a product which lets users register or log in to some apps by using just their phone numbers or email addresses without the use of passwords.

It’s easy to use and it does not need a Facebook account to log in and it’s available for over 230 country codes and in over 40 languages also being available for Android, iOS and web.

Let’s see what steps need to be followed for Android Account Kit integration.

1) Add or create an app on

2) From project dashboard, click on “+” buttons near PRODUCTS and select Account Kit. You will find Account Kit under PRODUCTS now. Click on settings and get started.

3) There you will find Account Kit Client Token that needs to be added in our app. Enable Client Access Token Flow should be set to Yes, so that app can receive token directly without addition server. You can select SMS Templates from the given. Email Settings for colors can be done from there.

4) From Settings > Basic in left panel add android app by adding Google Play Package Name and Key Hashes. Here is guidance to generate key hash for Development and Release app. Make sure your App Status is live on the top bar. Click on Save Changes. Console settings are now done.

Let’s take the integration to the coding level

5) Add dependency to your project.

repositories {
dependencies {
implementation ''

6) Inside you AndroidManifest.xml

lt;uses-permission android:name="android.permission.INTERNET"/>

7) Add these details to strings.xml

<string name="FACEBOOK_APP_ID">YOUR_FACEBOOK_APP_ID</string>

8) Add this to the AndroidManifest.xml inside application tag. The AccountKitActivity must be defined here. We can add a custom theme for AccountKitActivity which can be found here and demo file can be found here. Facebook app events are enabled by default that we can disable by making value false.

<meta-data android:name="com.facebook.sdk.ApplicationId"
android:value="@string/FACEBOOK_APP_ID" />
<meta-data android:name="com.facebook.accountkit.ClientToken"
android:value="@string/ACCOUNT_KIT_CLIENT_TOKEN" />
android:name="com.facebook.accountkit.ui.AccountKitActivity" />
<meta-data android:name="com.facebook.accountkit.FacebookAppEventsEnabled"
<meta-data android:name="com.facebook.accountkit.ApplicationName"

9) Checking for existing sessions.

import com.facebook.accountkit.AccountKit;
import com.facebook.accountkit.AccessToken;

AccessToken accessToken = AccountKit.getCurrentAccessToken();
if (accessToken != null) {
//Here we will handle already logged in users
} else {
//Here we will handle new or logged out users

10) Add SMS login with LoginType.PHONE and Email login with LoginType.EMAIL.

import com.facebook.accountkit.AccountKit;
import com.facebook.accountkit.ui.AccountKitActivity;
import com.facebook.accountkit.ui.AccountKitConfiguration;
import com.facebook.accountkit.ui.LoginType;

public static int APP_REQUEST_CODE = 23;

public void accountKitPhoneLogin() {
final Intent intent = new Intent(mContext, AccountKitActivity.class);
LoginType loginType;
loginType = LoginType.EMAIL; //For Email login
loginType = LoginType.PHONE;//For SMS login
AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
new AccountKitConfiguration.AccountKitConfigurationBuilder(
//Add your UIManager here
startActivityForResult(intent, APP_REQUEST_CODE);

11) Handling the response we get from Account Kit.

import com.facebook.accountkit.AccountKitLoginResult;
protected void onActivityResult(
final int requestCode,
final int resultCode,
final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// confirm that this response matches to your request
if (requestCode == APP_REQUEST_CODE) {
AccountKitLoginResult loginResult = data.getParcelableExtra(AccountKitLoginResult.RESULT_KEY);
String message;
if (loginResult.getError() != null) {
message = loginResult.getError().getErrorType().getMessage();
} else if (loginResult.wasCancelled()) {
message = "Login cancelled by user!";
} else {
if (loginResult.getAccessToken() != null) {
message = "Success:" + loginResult.getAccessToken().getAccountId();
} else {
message = String.format(
loginResult.getAuthorizationCode().substring(0, 10));
// Success!!! Start next activity…
Toast.makeText(this, message, Toast.LENGTH_LONG).show();

That’s it, the process is as simple as it seems and finally you can run this app and using account kit.

I have created demo app for that, which can be found on this repo. Here are some of the screenshots from app.

Interested & Talk More?

Let's brew something together!

WhatsApp Image