Android-এ একটি অ্যাকাউন্টে একাধিক প্রমাণীকরণ প্রদানকারীকে লিঙ্ক করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
আপনি একটি বিদ্যমান ব্যবহারকারীর অ্যাকাউন্টে প্রমাণীকরণ প্রদানকারীর শংসাপত্র লিঙ্ক করে একাধিক প্রমাণীকরণ প্রদানকারী ব্যবহার করে ব্যবহারকারীদের আপনার অ্যাপে সাইন ইন করার অনুমতি দিতে পারেন। ব্যবহারকারীরা সাইন ইন করতে যে প্রমাণীকরণ প্রদানকারীই ব্যবহার করুক না কেন একই Firebase ব্যবহারকারী আইডি দ্বারা শনাক্ত করা যায়৷ উদাহরণস্বরূপ, যে ব্যবহারকারী একটি পাসওয়ার্ড দিয়ে সাইন ইন করেছেন সে একটি Google অ্যাকাউন্ট লিঙ্ক করতে পারে এবং ভবিষ্যতে যেকোনো পদ্ধতিতে সাইন ইন করতে পারে৷ অথবা, একজন বেনামী ব্যবহারকারী একটি Facebook অ্যাকাউন্ট লিঙ্ক করতে পারেন এবং তারপরে, আপনার অ্যাপ ব্যবহার চালিয়ে যেতে Facebook-এ সাইন ইন করতে পারেন।
আপনি শুরু করার আগে
আপনার অ্যাপে দুই বা ততোধিক প্রমাণীকরণ প্রদানকারীর জন্য সমর্থন যোগ করুন (সম্ভবত বেনামী প্রমাণীকরণ সহ)।
একটি ব্যবহারকারীর অ্যাকাউন্টে অনুমোদন প্রদানকারীর শংসাপত্র লিঙ্ক করুন
একটি বিদ্যমান ব্যবহারকারী অ্যাকাউন্টে প্রমাণীকরণ প্রদানকারীর শংসাপত্রগুলি লিঙ্ক করতে:
যেকোনো প্রমাণীকরণ প্রদানকারী বা পদ্ধতি ব্যবহার করে ব্যবহারকারীকে সাইন ইন করুন।
FirebaseAuth.signInWith পদ্ধতিগুলির একটিতে কল করা পর্যন্ত নতুন প্রমাণীকরণ প্রদানকারীর জন্য সাইন-ইন প্রবাহ সম্পূর্ণ করুন, কিন্তু অন্তর্ভুক্ত নয়। উদাহরণস্বরূপ, ব্যবহারকারীর গুগল আইডি টোকেন, ফেসবুক অ্যাক্সেস টোকেন বা ইমেল এবং পাসওয়ার্ড পান।
নতুন প্রমাণীকরণ প্রদানকারীর জন্য একটি AuthCredential পান:
যদি শংসাপত্রগুলি ইতিমধ্যেই অন্য ব্যবহারকারীর অ্যাকাউন্টের সাথে লিঙ্ক করা থাকে তাহলে linkWithCredential এর কল ব্যর্থ হবে৷ এই পরিস্থিতিতে, আপনাকে অবশ্যই আপনার অ্যাপের জন্য উপযুক্ত হিসাবে অ্যাকাউন্ট এবং সংশ্লিষ্ট ডেটা মার্জিং পরিচালনা করতে হবে:
Kotlin
valprevUser=auth.currentUserauth.signInWithCredential(credential).addOnSuccessListener{result->
valcurrentUser=result.user// Merge prevUser and currentUser accounts and data// ...}.addOnFailureListener{// ...}
FirebaseUserprevUser=FirebaseAuth.getInstance().getCurrentUser();mAuth.signInWithCredential(credential).addOnCompleteListener(newOnCompleteListener<AuthResult>(){@OverridepublicvoidonComplete(@NonNullTask<AuthResult>task){FirebaseUsercurrentUser=task.getResult().getUser();// Merge prevUser and currentUser accounts and data// ...}});
linkWithCredential এ কল সফল হলে, ব্যবহারকারী এখন যেকোনো লিঙ্ক করা প্রমাণীকরণ প্রদানকারী ব্যবহার করে সাইন ইন করতে পারবেন এবং একই Firebase ডেটা অ্যাক্সেস করতে পারবেন।
একটি ব্যবহারকারীর অ্যাকাউন্ট থেকে একটি প্রমাণ প্রদানকারীকে লিঙ্কমুক্ত করুন৷
আপনি একটি অ্যাকাউন্ট থেকে একটি প্রমাণ প্রদানকারীকে লিঙ্কমুক্ত করতে পারেন, যাতে ব্যবহারকারী আর সেই প্রদানকারীর সাথে সাইন ইন করতে না পারে৷
একটি ব্যবহারকারীর অ্যাকাউন্ট থেকে একটি প্রমাণ প্রদানকারীকে আনলিঙ্ক করতে, unlink পদ্ধতিতে প্রদানকারীর আইডি পাস করুন৷ আপনি getProviderData কল করে ব্যবহারকারীর সাথে লিঙ্ক করা প্রমাণ প্রদানকারীর প্রদানকারী আইডি পেতে পারেন।
Kotlin
Firebase.auth.currentUser!!.unlink(providerId).addOnCompleteListener(this){task->
if(task.isSuccessful){// Auth provider unlinked from account// ...}}
[null,null,["2025-08-21 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["# Link Multiple Auth Providers to an Account on Android\n\n| **Important** : There is a [known issue](https://github.com/firebase/firebase-js-sdk/issues/7675) that prevents `linkWithCredentials()` from working correctly in some projects. See the issue report for a workaround and the status of a fix.\n\nYou can allow users to sign in to your app using multiple authentication\nproviders by linking auth provider credentials to an existing user account.\nUsers are identifiable by the same Firebase user ID regardless of the\nauthentication provider they used to sign in. For example, a user who signed in\nwith a password can link a Google account and sign in with either method in the\nfuture. Or, an anonymous user can link a Facebook account and then, later, sign\nin with Facebook to continue using your app.\n\nBefore you begin\n----------------\n\nAdd support for two or more authentication providers (possibly including\nanonymous authentication) to your app.\n\nLink auth provider credentials to a user account\n------------------------------------------------\n\nTo link auth provider credentials to an existing user account:\n\n1. Sign in the user using any authentication provider or method.\n2. Complete the sign-in flow for the new authentication provider up to, but not including, calling one of the [`FirebaseAuth.signInWith`](/docs/reference/android/com/google/firebase/auth/FirebaseAuth#public-method-summary) methods. For example, get the user's Google ID token, Facebook access token, or email and password.\n3. Get a `AuthCredential` for the new authentication provider:\n\n ##### Google Sign-In\n\n ### Kotlin\n\n ```kotlin\n val credential = GoogleAuthProvider.getCredential(googleIdToken, null)https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/kotlin/MainActivity.kt#L394-L394\n ```\n\n ### Java\n\n ```java\n AuthCredential credential = GoogleAuthProvider.getCredential(googleIdToken, null);https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/MainActivity.java#L479-L479\n ```\n\n ##### Facebook Login\n\n ### Kotlin\n\n ```kotlin\n val credential = FacebookAuthProvider.getCredential(token.token)https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/kotlin/MainActivity.kt#L401-L401\n ```\n\n ### Java\n\n ```java\n AuthCredential credential = FacebookAuthProvider.getCredential(token.getToken());https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/MainActivity.java#L487-L487\n ```\n\n ##### Email-password sign-in\n\n ### Kotlin\n\n ```kotlin\n val credential = EmailAuthProvider.getCredential(email, password)https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/kotlin/MainActivity.kt#L409-L409\n ```\n\n ### Java\n\n ```java\n AuthCredential credential = EmailAuthProvider.getCredential(email, password);https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/MainActivity.java#L495-L495\n ```\n4. Pass the `AuthCredential` object to the signed-in user's\n `linkWithCredential` method:\n\n ### Kotlin\n\n ```kotlin\n auth.currentUser!!.linkWithCredential(credential)\n .addOnCompleteListener(this) { task -\u003e\n if (task.isSuccessful) {\n Log.d(TAG, \"linkWithCredential:success\")\n val user = task.result?.user\n updateUI(user)\n } else {\n Log.w(TAG, \"linkWithCredential:failure\", task.exception)\n Toast.makeText(\n baseContext,\n \"Authentication failed.\",\n Toast.LENGTH_SHORT,\n ).show()\n updateUI(null)\n }\n }https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/kotlin/AnonymousAuthActivity.kt#L66-L81\n ```\n\n ### Java\n\n ```java\n mAuth.getCurrentUser().linkWithCredential(credential)\n .addOnCompleteListener(this, new OnCompleteListener\u003cAuthResult\u003e() {\n @Override\n public void onComplete(@NonNull Task\u003cAuthResult\u003e task) {\n if (task.isSuccessful()) {\n Log.d(TAG, \"linkWithCredential:success\");\n FirebaseUser user = task.getResult().getUser();\n updateUI(user);\n } else {\n Log.w(TAG, \"linkWithCredential:failure\", task.getException());\n Toast.makeText(AnonymousAuthActivity.this, \"Authentication failed.\",\n Toast.LENGTH_SHORT).show();\n updateUI(null);\n }\n }\n });https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/AnonymousAuthActivity.java#L91-L106\n ```\n\n The call to `linkWithCredential` will fail if the credentials are\n already linked to another user account. In this situation, you must handle\n merging the accounts and associated data as appropriate for your app: \n\n ### Kotlin\n\n ```kotlin\n val prevUser = auth.currentUser\n auth.signInWithCredential(credential)\n .addOnSuccessListener { result -\u003e\n val currentUser = result.user\n // Merge prevUser and currentUser accounts and data\n // ...\n }\n .addOnFailureListener {\n // ...\n }https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/kotlin/MainActivity.kt#L250-L259\n ```\n\n ### Java\n\n ```java\n FirebaseUser prevUser = FirebaseAuth.getInstance().getCurrentUser();\n mAuth.signInWithCredential(credential)\n .addOnCompleteListener(new OnCompleteListener\u003cAuthResult\u003e() {\n @Override\n public void onComplete(@NonNull Task\u003cAuthResult\u003e task) {\n FirebaseUser currentUser = task.getResult().getUser();\n // Merge prevUser and currentUser accounts and data\n // ...\n }\n });https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/MainActivity.java#L303-L312\n ```\n\nIf the call to `linkWithCredential` succeeds, the user can now sign in using\nany linked authentication provider and access the same Firebase data.\n\nUnlink an auth provider from a user account\n-------------------------------------------\n\nYou can unlink an auth provider from an account, so that the user can no\nlonger sign in with that provider.\n\nTo unlink an auth provider from a user account, pass the provider ID to the\n`unlink` method. You can get the provider IDs of the auth providers\nlinked to a user by calling [`getProviderData`](/docs/reference/android/com/google/firebase/auth/FirebaseUser#getProviderData()). \n\n### Kotlin\n\n```kotlin\nFirebase.auth.currentUser!!.unlink(providerId)\n .addOnCompleteListener(this) { task -\u003e\n if (task.isSuccessful) {\n // Auth provider unlinked from account\n // ...\n }\n }https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/kotlin/MainActivity.kt#L265-L271\n```\n\n### Java\n\n```java\nmAuth.getCurrentUser().unlink(providerId)\n .addOnCompleteListener(this, new OnCompleteListener\u003cAuthResult\u003e() {\n @Override\n public void onComplete(@NonNull Task\u003cAuthResult\u003e task) {\n if (task.isSuccessful()) {\n // Auth provider unlinked from account\n // ...\n }\n }\n });https://github.com/firebase/snippets-android/blob/391c1646eacf44d2aab3f76bcfa60dfc6c14acf1/auth/app/src/main/java/com/google/firebase/quickstart/auth/MainActivity.java#L321-L330\n```"]]