samyak2403
Firebase-OTP-Verifaction
Kotlin

Firebase OTP Verification in Android using Kotlin

Last updated Jul 28, 2026
10
Stars
2
Forks
0
Issues
0
Stars/day
Attention Score
0
Language breakdown
Kotlin 100.0%
β–Έ Files click to expand
README

Firebase OTP Verification in Android using Kotlin

A robust Android application that integrates Firebase for OTP (One-Time Password) verification. This project provides a seamless experience for phone number authentication with auto-retrieval of OTP, resend functionality, and a user-friendly interface.

Features

  • Phone Number Authentication: Secure user authentication via OTP sent to their phone number.
  • Auto OTP Retrieval: Automatically retrieves the OTP from SMS for a smoother user experience.
  • Resend OTP: Option to resend OTP in case the original message is missed.
  • Firebase Integration: Utilizes Firebase Authentication for managing phone number verification.
  • Kotlin Implementation: Entire app built using Kotlin, following best practices and clean code architecture.

Screenshots

Prerequisites

  • Android Studio: Latest version recommended.
  • Firebase Project: You need to have a Firebase project set up.
  • Google Play Services: Ensure that Google Play Services is updated on the device.

Getting Started

Follow these steps to set up the project locally:

1. Clone the Repository

https://github.com/samyak2403/Firebase-OTP-Verifaction.git
cd Firebase-OTP-Verifaction-repository

Firebase OTP Verification in Android (Kotlin)

This project demonstrates how to implement OTP (One-Time Password) verification in an Android application using Firebase Authentication.

Table of Contents

Prerequisites

  • Android Studio (latest version)
  • A Firebase account
  • Basic knowledge of Kotlin and Android development

Setup Firebase in Your Project

  • Create a Firebase Project:
- Go to the Firebase Console. - Click on Add Project and follow the instructions to create a new project.
  • Add Your Android App to Firebase:
- In the Firebase Console, select your project and click on Add App. - Choose Android and enter your app's package name. - Download the google-services.json file and place it in the app/ directory of your Android project.
  • Generate SHA-256 Key:
- Open a terminal and run the following command:
keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore
- If prompted for a password, use android (default password). - Copy the SHA-256 key from the output. - In the Firebase Console, navigate to Project Settings > General. Under the Your apps section, click on Add Fingerprint and paste the SHA-256 key.
  • Enable Phone Authentication:
- In the Firebase Console, go to Authentication > Sign-in method. - Enable the Phone sign-in provider.

Add Required Dependencies

  • Add Google services classpath:
- In your project-level build.gradle file, add the following:
buildscript {
         repositories {
             google()
             mavenCentral()
         }
         dependencies {
             classpath 'com.google.gms:google-services:4.3.15' // Check for the latest version
         }
     }
  • Add Firebase dependencies:
- In your app-level build.gradle file, add the Firebase dependencies:
plugins {
         id 'com.android.application'
         id 'kotlin-android'
         id 'com.google.gms.google-services'
     }

dependencies { implementation platform('com.google.firebase:firebase-bom:32.0.0') // Check for the latest version implementation 'com.google.firebase:firebase-auth-ktx' }

## Modify AndroidManifest.xml Add the following permissions and receivers:

<uses-permission android:name="android.permission.RECEIVE_SMS"/> <uses-permission android:name="android.permission.READ_SMS"/>

<application> ... <receiver android:name=".OTP_Receiver" android:exported="true" android:permission="com.google.android.gms.auth.api.phone.permission.SEND"/> </application>

  • Sync your project: After adding the dependencies, sync your project in Android Studio.

Implement OTP Verification

Follow the steps below to implement OTP verification in your Android app:

  • Request OTP:
- Use Firebase Authentication to send an OTP to the user's phone number.
  • Verify OTP:
- Allow the user to input the OTP and verify it using Firebase Authentication.

For detailed code examples, refer to the official Firebase documentation or the project’s source code.

Project Structure:

app/
β”œβ”€β”€ src/main/java/app/my/otpverification/
β”‚   β”œβ”€β”€ OtpSendActivity.kt       # Handles sending OTP
β”‚   β”œβ”€β”€ OtpVerifyActivity.kt     # Handles OTP verification
β”‚   β”œβ”€β”€ OTP_Receiver.kt          # BroadcastReceiver for SMS retrieval
β”‚   └── MainActivity.kt          # Post-authentication main screen
└── src/main/res/layout/         # XML layouts for activities

License

This project is licensed under the MIT License - see the LICENSE file for details.

Β© 2026 GitRepoTrend Β· samyak2403/Firebase-OTP-Verifaction Β· Updated daily from GitHub