You can use Firebase Authentication to sign in a user by sending them an email containing a link, which they can click to sign in. In the process, the user's email address is also verified.
There are numerous benefits to signing in by email:
- সহজ সাইন-আপ এবং সাইন-ইন।
- Lower risk of password reuse across applications, which can undermine security of even well-selected passwords.
- The ability to authenticate a user while also verifying that the user is the legitimate owner of an email address.
- A user only needs an accessible email account to sign in. No ownership of a phone number or social media account is required.
- A user can sign in securely without the need to provide (or remember) a password, which can be cumbersome on a mobile device.
- একজন বিদ্যমান ব্যবহারকারী যিনি পূর্বে ইমেল আইডেন্টিফায়ার (পাসওয়ার্ড বা ফেডারেটেড) দিয়ে সাইন ইন করতেন, তাকে শুধুমাত্র ইমেল দিয়ে সাইন ইন করার জন্য আপগ্রেড করা যেতে পারে। উদাহরণস্বরূপ, একজন ব্যবহারকারী যিনি তার পাসওয়ার্ড ভুলে গেছেন, তিনি পাসওয়ার্ড রিসেট করার প্রয়োজন ছাড়াই সাইন ইন করতে পারবেন।
শুরু করার আগে
আপনার অ্যান্ড্রয়েড প্রজেক্ট সেট আপ করুন
যদি আগে থেকে না করে থাকেন, তাহলে আপনার অ্যান্ড্রয়েড প্রজেক্টে ফায়ারবেস যোগ করুন ।
আপনার মডিউল (অ্যাপ-লেভেল) গ্রেডল ফাইলে (সাধারণত
<project>/<app-module>/build.gradle.ktsঅথবা<project>/<app-module>/build.gradle), অ্যান্ড্রয়েডের জন্য Firebase Authentication লাইব্রেরির ডিপেন্ডেন্সি যোগ করুন। লাইব্রেরির ভার্সনিং নিয়ন্ত্রণের জন্য আমরা Firebase Android BoM ব্যবহার করার পরামর্শ দিই।Also, as part of setting up Firebase Authentication , you need to add the Google Play services SDK to your app.
dependencies { // Import the BoM for the Firebase platform implementation(platform("com.google.firebase:firebase-bom:34.15.0")) // Add the dependency for the Firebase Authentication library // When using the BoM, you don't specify versions in Firebase library dependencies implementation("com.google.firebase:firebase-auth")
// Also add the dependency for the Google Play services library and specify its version implementation("com.google.android.gms:play-services-auth:21.6.0") }By using the Firebase Android BoM , your app will always use compatible versions of Firebase Android libraries.
(Alternative) Add Firebase library dependencies without using the BoM
If you choose not to use the Firebase BoM , you must specify each Firebase library version in its dependency line.
Note that if you use multiple Firebase libraries in your app, we strongly recommend using the BoM to manage library versions, which ensures that all versions are compatible.
dependencies { // Add the dependency for the Firebase Authentication library // When NOT using the BoM, you must specify versions in Firebase library dependencies implementation("com.google.firebase:firebase-auth:24.1.0")
// Also add the dependency for the Google Play services library and specify its version implementation("com.google.android.gms:play-services-auth:21.6.0") }
Enable Email Link sign-in for your Firebase project
To sign in users by email link, you must first enable the Email provider and Email link sign-in method for your Firebase project:
In the Firebase console, go to Security > Authentication .
In the Sign-in method tab, enable the Email/Password sign-in provider. Note that email/password sign-in must be enabled to use email link sign-in.
In the same section, enable the Email link (passwordless sign-in) sign-in provider.
সংরক্ষণ করুন- এ ক্লিক করুন।
Send an authentication link to the user's email address
প্রমাণীকরণ প্রক্রিয়া শুরু করতে, ব্যবহারকারীকে এমন একটি ইন্টারফেস দেখান যেখানে তার ইমেল ঠিকানা দিতে বলা হবে এবং তারপর Firebase-কে ব্যবহারকারীর ইমেলে প্রমাণীকরণ লিঙ্কটি পাঠানোর অনুরোধ জানাতে sendSignInLinkToEmail কল করুন।
Construct the ActionCodeSettings object, which provides Firebase with instructions on how to construct the email link. Set the following fields:
url: The deep link to embed and any additional state to be passed along. If you haven't already, add the domain of the link to the list of authorized domains:In the Firebase console, go to the Security > Authentication > Settings tab .
In the Authorized domains section, click Add domain , and add the link's domain.
The link will redirect the user to this URL if the app is not installed on their device and the app was not able to be installed.
-
androidPackageNameandiOSBundleId: Helps Firebase Authentication determine if it should create a web-only or mobile link which is opened on an Android or Apple device. -
handleCodeInApp: এটিকে true-তে সেট করুন। অন্যান্য আউট-অফ-ব্যান্ড ইমেল অ্যাকশনের (যেমন পাসওয়ার্ড রিসেট এবং ইমেল ভেরিফিকেশন) মতো নয়, সাইন-ইন অপারেশনটি সবসময় অ্যাপের মধ্যেই সম্পন্ন করতে হবে। এর কারণ হলো, ফ্লো-এর শেষে ব্যবহারকারীকে সাইন-ইন করা অবস্থায় এবং তার অথেন্টিকেশন স্টেট অ্যাপের মধ্যেই সংরক্ষিত থাকার কথা। -
linkDomain: যখন কোনো প্রোজেক্টের জন্য কাস্টম Hosting লিঙ্ক ডোমেইন নির্ধারণ করা হয়, তখন নির্দিষ্ট মোবাইল অ্যাপ দ্বারা লিঙ্কটি খোলার জন্য কোনটি ব্যবহার করা হবে তা নির্দিষ্ট করুন। অন্যথায়, ডিফল্ট ডোমেইন স্বয়ংক্রিয়ভাবে নির্বাচিত হয় (উদাহরণস্বরূপ,PROJECT_ID .firebaseapp.com) -
dynamicLinkDomain: Deprecated. Don't specify this parameter.
Kotlin
val actionCodeSettings = actionCodeSettings { // URL you want to redirect back to. The domain (www.example.com) for this // URL must be whitelisted in the Firebase Console. url = "https://www.example.com/finishSignUp?cartId=1234" // This must be true handleCodeInApp = true setIOSBundleId("com.example.ios") setAndroidPackageName( "com.example.android", true, // installIfNotAvailable "12", // minimumVersion ) }
Java
ActionCodeSettings actionCodeSettings = ActionCodeSettings.newBuilder() // URL you want to redirect back to. The domain (www.example.com) for this // URL must be whitelisted in the Firebase Console. .setUrl("https://www.example.com/finishSignUp?cartId=1234") // This must be true .setHandleCodeInApp(true) .setIOSBundleId("com.example.ios") .setAndroidPackageName( "com.example.android", true, /* installIfNotAvailable */ "12" /* minimumVersion */) .build();
To learn more on ActionCodeSettings, refer to the Passing State in Email Actions section.
ব্যবহারকারীর ইমেইল ঠিকানা জিজ্ঞাসা করুন।
Send the authentication link to the user's email, and save the user's email in case the user completes the email sign-in on the same device.
Kotlin
Firebase.auth.sendSignInLinkToEmail(email, actionCodeSettings) .addOnCompleteListener { task -> if (task.isSuccessful) { Log.d(TAG, "Email sent.") } }
Java
FirebaseAuth auth = FirebaseAuth.getInstance(); auth.sendSignInLinkToEmail(email, actionCodeSettings) .addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()) { Log.d(TAG, "Email sent."); } } });
ইমেল লিঙ্কের মাধ্যমে সাইন ইন সম্পন্ন করুন।
নিরাপত্তা উদ্বেগ
অনাকাঙ্ক্ষিত ব্যবহারকারী বা অনাকাঙ্ক্ষিত ডিভাইসে সাইন-ইন করার জন্য সাইন-ইন লিঙ্কটি যাতে ব্যবহার করা না যায়, সেজন্য Firebase Authentication সাইন-ইন প্রক্রিয়া সম্পন্ন করার সময় ব্যবহারকারীর ইমেল ঠিকানা প্রদান করা আবশ্যক করে। সাইন-ইন সফল হওয়ার জন্য, এই ইমেল ঠিকানাটি অবশ্যই সেই ঠিকানার সাথে মিলতে হবে যেখানে সাইন-ইন লিঙ্কটি মূলত পাঠানো হয়েছিল।
যেসব ব্যবহারকারী যে ডিভাইসে সাইন-ইন লিঙ্কের জন্য অনুরোধ করেন, সেই একই ডিভাইসে লিঙ্কটি খোলেন, তাদের জন্য এই প্রক্রিয়াটিকে আরও সহজ করতে, সাইন-ইন ইমেল পাঠানোর সময় তাদের ইমেল ঠিকানা স্থানীয়ভাবে সংরক্ষণ করুন—উদাহরণস্বরূপ, SharedPreferences ব্যবহার করে। তারপর, প্রক্রিয়াটি সম্পন্ন করতে এই ঠিকানাটি ব্যবহার করুন। রিডাইরেক্ট ইউআরএল প্যারামিটারে ব্যবহারকারীর ইমেল পাস করবেন না এবং এটি পুনরায় ব্যবহার করবেন না, কারণ এটি সেশন ইনজেকশন সক্রিয় করতে পারে।
সাইন-ইন সম্পন্ন হওয়ার পর, ব্যবহারকারীর পূর্ববর্তী যেকোনো যাচাইবিহীন সাইন-ইন পদ্ধতি মুছে ফেলা হবে এবং বিদ্যমান সেশনগুলো বাতিল হয়ে যাবে। উদাহরণস্বরূপ, যদি কেউ পূর্বে একই ইমেল এবং পাসওয়ার্ড দিয়ে একটি যাচাইবিহীন অ্যাকাউন্ট তৈরি করে থাকে, তবে ব্যবহারকারীর পাসওয়ার্ডটি মুছে ফেলা হবে, যাতে সেই ছদ্মবেশী ব্যক্তি, যিনি মালিকানা দাবি করে অ্যাকাউন্টটি তৈরি করেছিলেন, তিনি পুনরায় সেই যাচাইবিহীন ইমেল এবং পাসওয়ার্ড দিয়ে সাইন-ইন করতে না পারেন।
Also make sure you use an HTTPS URL in production to avoid your link being potentially intercepted by intermediary servers.
অ্যান্ড্রয়েড অ্যাপে সাইন-ইন সম্পন্ন করা
Firebase Authentication একটি মোবাইল ডিভাইসে ইমেল লিঙ্ক পাঠাতে Firebase Hosting ব্যবহার করে। মোবাইল অ্যাপ্লিকেশনের মাধ্যমে সাইন-ইন সম্পন্ন করার জন্য, অ্যাপ্লিকেশনটিকে আগত অ্যাপ্লিকেশন লিঙ্কটি শনাক্ত করতে, অন্তর্নিহিত ডিপ লিঙ্কটি পার্স করতে এবং তারপরে সাইন-ইন সম্পূর্ণ করতে কনফিগার করতে হবে। আরও জানতে, অ্যান্ড্রয়েড অ্যাপ লিঙ্কস ডকুমেন্টেশন দেখুন।
Firebase Hosting কনফিগার করুন
মোবাইল অ্যাপ্লিকেশনে খোলার জন্য কোনো লিঙ্ক তৈরি ও পাঠানোর সময় Firebase Authentication Firebase Hosting ডোমেইন ব্যবহার করে। আপনার জন্য একটি ডিফল্ট Firebase Hosting ডোমেইন আগে থেকেই কনফিগার করা আছে।
Firebase Hosting ডোমেইনগুলো কনফিগার করুন:
In the Firebase console, go to Hosting & Serverless > Hosting .
মোবাইল অ্যাপ্লিকেশনে খোলা ইমেল লিঙ্কের জন্য যদি আপনি ডিফল্ট ডোমেইন ব্যবহার করতে চান, তাহলে আপনার ডিফল্ট সাইটে যান এবং আপনার ডিফল্ট Hosting ডোমেইনটি নোট করে নিন। একটি ডিফল্ট Hosting ডোমেইন সাধারণত দেখতে এইরকম হয়:
PROJECT_ID .firebaseapp.com.You'll need this value when you configure your app to intercept the incoming link.
If you want to use a custom domain for the email link, you can register one with Firebase Hosting and use that for the link's domain.
অ্যান্ড্রয়েড অ্যাপ্লিকেশন কনফিগার করা:
আপনার অ্যান্ড্রয়েড অ্যাপ্লিকেশন থেকে এই লিঙ্কগুলি পরিচালনা করার জন্য, Firebase কনসোল প্রজেক্ট সেটিংসে আপনার অ্যাপের প্যাকেজ নামটি উল্লেখ করতে হবে। এছাড়াও, অ্যাপ্লিকেশন সার্টিফিকেটের SHA-1 এবং SHA-256 প্রদান করতে হবে।
আপনি যদি এই লিঙ্কগুলিকে একটি নির্দিষ্ট অ্যাক্টিভিটিতে রিডাইরেক্ট করতে চান, তাহলে আপনাকে আপনার
AndroidManifest.xmlফাইলে একটি ইন্টেন্ট ফিল্টার কনফিগার করতে হবে। ইন্টেন্ট ফিল্টারটি আপনার ডোমেইনের ইমেল লিঙ্কগুলি শনাক্ত করবে।AndroidManifest.xmlএ:<intent-filter android:autoVerify="true"> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT" /> <data android:scheme="https" android:host="<PROJECT_ID>.firebaseapp.com or your custom domain" android:pathPrefix="/__/auth/links" /> </intent-filter>When users open a hosting link with the
/__/auth/linkspath and the scheme and host you specify, your app will start the activity with this intent filter to handle the link .
লিঙ্ক যাচাই করুন এবং সাইন ইন করুন
After you receive the link as described above, verify that it is meant for email link authentication and complete the sign in.
Kotlin
val auth = Firebase.auth val intent = intent val emailLink = intent.data.toString() // Confirm the link is a sign-in with email link. if (auth.isSignInWithEmailLink(emailLink)) { // Retrieve this from wherever you stored it val email = "someemail@domain.com" // The client SDK will parse the code from the link for you. auth.signInWithEmailLink(email, emailLink) .addOnCompleteListener { task -> if (task.isSuccessful) { Log.d(TAG, "Successfully signed in with email link!") val result = task.result // You can access the new user via result.getUser() // Additional user info profile *not* available via: // result.getAdditionalUserInfo().getProfile() == null // You can check if the user is new or existing: // result.getAdditionalUserInfo().isNewUser() } else { Log.e(TAG, "Error signing in with email link", task.exception) } } }
Java
FirebaseAuth auth = FirebaseAuth.getInstance(); Intent intent = getIntent(); String emailLink = intent.getData().toString(); // Confirm the link is a sign-in with email link. if (auth.isSignInWithEmailLink(emailLink)) { // Retrieve this from wherever you stored it String email = "someemail@domain.com"; // The client SDK will parse the code from the link for you. auth.signInWithEmailLink(email, emailLink) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { Log.d(TAG, "Successfully signed in with email link!"); AuthResult result = task.getResult(); // You can access the new user via result.getUser() // Additional user info profile *not* available via: // result.getAdditionalUserInfo().getProfile() == null // You can check if the user is new or existing: // result.getAdditionalUserInfo().isNewUser() } else { Log.e(TAG, "Error signing in with email link", task.getException()); } } }); }
To learn more on how to handle sign-in with email link in an Apple application, refer to the Apple platforms guide .
To learn about how to handle sign-in with email link in a web application, refer to the Web guide .
ইমেল লিঙ্কের মাধ্যমে সংযোগ/পুনঃপ্রমাণীকরণ
আপনি এই প্রমাণীকরণ পদ্ধতিটি কোনো বিদ্যমান ব্যবহারকারীর সাথেও লিঙ্ক করতে পারেন। উদাহরণস্বরূপ, যে ব্যবহারকারী পূর্বে অন্য কোনো প্রদানকারী, যেমন একটি ফোন নম্বর, ব্যবহার করে প্রমাণীকৃত হয়েছেন, তিনি তার বিদ্যমান অ্যাকাউন্টে এই সাইন-ইন পদ্ধতিটি যোগ করতে পারেন।
The difference would be in the second half of the operation:
Kotlin
// Construct the email link credential from the current URL. val credential = EmailAuthProvider.getCredentialWithLink(email, emailLink) // Link the credential to the current user. Firebase.auth.currentUser!!.linkWithCredential(credential) .addOnCompleteListener { task -> if (task.isSuccessful) { Log.d(TAG, "Successfully linked emailLink credential!") val result = task.result // You can access the new user via result.getUser() // Additional user info profile *not* available via: // result.getAdditionalUserInfo().getProfile() == null // You can check if the user is new or existing: // result.getAdditionalUserInfo().isNewUser() } else { Log.e(TAG, "Error linking emailLink credential", task.exception) } }
Java
// Construct the email link credential from the current URL. AuthCredential credential = EmailAuthProvider.getCredentialWithLink(email, emailLink); // Link the credential to the current user. auth.getCurrentUser().linkWithCredential(credential) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { Log.d(TAG, "Successfully linked emailLink credential!"); AuthResult result = task.getResult(); // You can access the new user via result.getUser() // Additional user info profile *not* available via: // result.getAdditionalUserInfo().getProfile() == null // You can check if the user is new or existing: // result.getAdditionalUserInfo().isNewUser() } else { Log.e(TAG, "Error linking emailLink credential", task.getException()); } } });
This can also be used to re-authenticate an email link user before running a sensitive operation.
Kotlin
// Construct the email link credential from the current URL. val credential = EmailAuthProvider.getCredentialWithLink(email, emailLink) // Re-authenticate the user with this credential. Firebase.auth.currentUser!!.reauthenticateAndRetrieveData(credential) .addOnCompleteListener { task -> if (task.isSuccessful) { // User is now successfully reauthenticated } else { Log.e(TAG, "Error reauthenticating", task.exception) } }
Java
// Construct the email link credential from the current URL. AuthCredential credential = EmailAuthProvider.getCredentialWithLink(email, emailLink); // Re-authenticate the user with this credential. auth.getCurrentUser().reauthenticateAndRetrieveData(credential) .addOnCompleteListener(new OnCompleteListener<AuthResult>() { @Override public void onComplete(@NonNull Task<AuthResult> task) { if (task.isSuccessful()) { // User is now successfully reauthenticated } else { Log.e(TAG, "Error reauthenticating", task.getException()); } } });
তবে, যেহেতু প্রক্রিয়াটি এমন কোনো ভিন্ন ডিভাইসে শেষ হতে পারে যেখানে মূল ব্যবহারকারী লগ ইন করা ছিলেন না, তাই এই প্রক্রিয়াটি সম্পূর্ণ নাও হতে পারে। সেক্ষেত্রে, ব্যবহারকারীকে একই ডিভাইসে লিঙ্কটি খুলতে বাধ্য করার জন্য একটি ত্রুটি দেখানো যেতে পারে। অপারেশনের ধরন এবং ব্যবহারকারীর ইউআইডি (uid) সম্পর্কে তথ্য প্রদানের জন্য লিঙ্কে কিছু স্টেট (state) পাঠানো যেতে পারে।
Deprecated: Firebase Dynamic Links based verification
Email link authentication previously relied on Firebase Dynamic Links , which will be shut down on August 25, 2025 .
We've published an alternative solution in the Firebase Authentication Android SDK v23.2.0+ and Firebase BoM v33.9.0+.
If your app uses the old style links, you should migrate your app to the new Firebase Hosting based system.
Deprecated: Differentiating email-password from email link
যদি আপনি আপনার প্রজেক্টটি ১৫ই সেপ্টেম্বর, ২০২৩ বা তার পরে তৈরি করে থাকেন, তাহলে ইমেইল এনুমারেশন প্রোটেকশন ডিফল্টরূপে সক্রিয় থাকে। এই ফিচারটি আপনার প্রজেক্টের ইউজার অ্যাকাউন্টগুলোর নিরাপত্তা উন্নত করে, কিন্তু এটি fetchSignInMethodsForEmail() মেথডটিকে নিষ্ক্রিয় করে দেয়, যা আমরা পূর্বে আইডেন্টিফায়ার-ফার্স্ট ফ্লো বাস্তবায়নের জন্য সুপারিশ করেছিলাম।
Although you can disable email enumeration protection for your project, we recommend against doing so.
See the documentation on email enumeration protection for more details.
পরবর্তী পদক্ষেপ
কোনো ব্যবহারকারী প্রথমবার সাইন ইন করার পর, একটি নতুন ব্যবহারকারী অ্যাকাউন্ট তৈরি হয় এবং সেটি ব্যবহারকারীর সাইন ইন করার ক্রেডেনশিয়াল—অর্থাৎ, ইউজার নেম ও পাসওয়ার্ড, ফোন নম্বর, বা অথোরাইজেশন প্রোভাইডারের তথ্যের—সাথে লিঙ্ক করা হয়। এই নতুন অ্যাকাউন্টটি আপনার ফায়ারবেস প্রজেক্টের অংশ হিসেবে সংরক্ষিত থাকে এবং ব্যবহারকারী কীভাবে সাইন ইন করছেন তা নির্বিশেষে, আপনার প্রজেক্টের প্রতিটি অ্যাপে তাকে শনাক্ত করতে এটি ব্যবহার করা যেতে পারে।
In your apps, you can get the user's basic profile information from the
FirebaseUserobject. See Manage Users .In your Firebase Realtime Database and Cloud Storage Security Rules , you can get the signed-in user's unique user ID from the
authvariable, and use it to control what data a user can access.
You can allow users to sign in to your app using multiple authentication providers by linking auth provider credentials to an existing user account.
কোনো ব্যবহারকারীকে সাইন আউট করতে, signOut কল করুন:
Kotlin
Firebase.auth.signOut()
Java
FirebaseAuth.getInstance().signOut();