Twitter digits authentication


Oct 30, 2017
Oct 31, 2017 (Retired)
Fenil Patel (Fenscode)
Fenil Patel (Fenscode)
Source code


Twitter Digit Authentication



Phone number authentication:

What is the use of “Twitter digits authentication”?

Email and password signup is a technology that has not been innovated on in decades. Signup forms are cumbersome and repetitive. When users forget their credentials and fail to sign in, you can lose customers. So, that's why here twitter digits comes in picture. It use user's phone number to authentication user and send One time password (OTP) code on that number for authenticate genuine user for app. Twitter take phone number for authenticate user, fact behind that, phone number is easly we remember. Twitter digits provided their service for both Android and iOS.

How to integrate and use Twitter digits in your App ?

1. Add the Kit to Your app's build.gradle
buildscript {
repositories {
maven { url '' }

dependencies {
// The Fabric Gradle plugin uses an open ended version to react
// quickly to Android tooling updates
classpath ''
Add following dependency to Your app's common build.gradle
apply plugin: 'io.fabric'
repositories {
maven { url '' }

dependencies {
compile('') {
transitive = true;
Add Your API Key at “AndroidManifest.xml”
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher"
android:label="@string/app_name" android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" android:label="@string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<uses-permission android:name="android.permission.INTERNET" />
<meta-data android:name="io.fabric.ApiKey"
android:value="****a6e7c4913e66601a*********************" />
Tap on “Create Application” button, and create you twitter digits application. When you

made application, than your API key generated automatically.

Import packages in yor
## Intialize your Twitter API KEY and Twitter Secret key on TwitterAuthConfig constuctor.
Both the key are available on Application dashboard.
## And after that build your your app with Fabric.
public class MainActivity extends ActionBarActivity
@Override protected void onCreate(Bundle savedInstanceState) {
TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY,TWITTER_SECRET);
Fabric.with(this, new TwitterCore(authConfig), new Digits.Builder().build());
........... .......... ..............
Rebuild your project:

Build your project and see everything going to work!

You can see, some demo Example on following link:


Integrate your theme in your digits App:

- Customize Digits to use your own fonts and colors.
- Create a custom theme that can be assigned to the Digits authentication screens.
1. Add your theme elements in themes.xml
<style name="CustomDigitsTheme" parent="android:Theme.Light">
<item name="android:textColorPrimary">@android:color/black</item>
<item name="android:textColorSecondary">@android:color/darker_gray</item>
<item name="android:windowBackground">@android:color/darker_gray</item>
<item name="android:textColorLink">#ff398622</item>
<item name="dgts__accentColor">#ffacee</item>
2. Set the Digits theme in

To use this code you’ll need to already have a DigitsAuthButton in your app. Go through the “Sign In with Phone Number” tutorial if you need one.

Adding a theme to DigitsAuthButton will affect the entire sign in flow. You can change fonts, colors, and add your app’s logo.

Build your custom theme with Digits.Builder class.


Digits.Builder digitsBuilder = new Digits.Builder().withTheme(;
Fabric.with(this, new TwitterCore(authConfig),;

Try it out!

Run the app. You should see that after tapping on the "Use my phone number" button, your theme is applied to the Digits authentication screens.

Digits was shutdown on September 30, 2017. You can still migrate your users to Firebase Auth using the following guide.