ওয়েব অ্যাপে OpenID কানেক্ট ব্যবহার করে প্রমাণীকরণ করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
আপনি যদি Firebase Authentication with Identity Platform আপগ্রেড করে থাকেন, তাহলে আপনি আপনার পছন্দের OpenID Connect (OIDC) অনুগত প্রদানকারী ব্যবহার করে Firebase-এর মাধ্যমে আপনার ব্যবহারকারীদের প্রমাণীকরণ করতে পারেন। এটি ফায়ারবেস দ্বারা স্থানীয়ভাবে সমর্থিত নয় এমন পরিচয় প্রদানকারী ব্যবহার করা সম্ভব করে।
আপনি শুরু করার আগে
একটি OIDC প্রদানকারী ব্যবহার করে ব্যবহারকারীদের সাইন ইন করতে, আপনাকে প্রথমে প্রদানকারীর কাছ থেকে কিছু তথ্য সংগ্রহ করতে হবে:
ক্লায়েন্ট আইডি : প্রদানকারীর জন্য অনন্য একটি স্ট্রিং যা আপনার অ্যাপকে শনাক্ত করে। আপনার সরবরাহকারী আপনার সমর্থন করা প্রতিটি প্ল্যাটফর্মের জন্য আপনাকে একটি আলাদা ক্লায়েন্ট আইডি বরাদ্দ করতে পারে। এটি আপনার প্রদানকারীর দ্বারা জারি করা আইডি টোকেনে aud
দাবির একটি মান।
ক্লায়েন্ট সিক্রেট : একটি গোপন স্ট্রিং যা প্রদানকারী একটি ক্লায়েন্ট আইডির মালিকানা নিশ্চিত করতে ব্যবহার করে। প্রতিটি ক্লায়েন্ট আইডির জন্য, আপনার একটি মিলিত ক্লায়েন্ট গোপনীয়তার প্রয়োজন হবে। (যদি আপনি প্রমাণীকরণ কোড ফ্লো ব্যবহার করেন তবেই এই মানটি প্রয়োজন, যা দৃঢ়ভাবে সুপারিশ করা হয়।)
ইস্যুকারী : একটি স্ট্রিং যা আপনার প্রদানকারীকে সনাক্ত করে। এই মানটি অবশ্যই একটি URL হতে হবে যা /.well-known/openid-configuration
এর সাথে যুক্ত হলে, প্রদানকারীর OIDC আবিষ্কারের নথির অবস্থান। উদাহরণস্বরূপ, যদি ইস্যুকারী https://auth.example.com
হয়, তাহলে আবিষ্কারের নথিটি অবশ্যই https://auth.example.com/.well-known/openid-configuration
এ উপলব্ধ হতে হবে।
আপনার কাছে উপরের তথ্য পাওয়ার পরে, আপনার Firebase প্রকল্পের জন্য একটি সাইন-ইন প্রদানকারী হিসাবে OpenID Connect সক্ষম করুন:
আপনার JavaScript প্রকল্পে Firebase যোগ করুন ।
আপনি যদি Firebase Authentication with Identity Platform আপগ্রেড না করে থাকেন তবে তা করুন৷ OpenID Connect প্রমাণীকরণ শুধুমাত্র আপগ্রেড করা প্রকল্পগুলিতে উপলব্ধ।
Firebase কনসোলের সাইন-ইন প্রদানকারী পৃষ্ঠায়, নতুন প্রদানকারী যোগ করুন-এ ক্লিক করুন এবং তারপর OpenID Connect-এ ক্লিক করুন।
আপনি অনুমোদন কোড প্রবাহ বা অন্তর্নিহিত অনুদান প্রবাহ ব্যবহার করবেন কিনা তা নির্বাচন করুন৷
যদি আপনার প্রদানকারী এটি সমর্থন করে তবে আপনার সর্বদা কোড প্রবাহ ব্যবহার করা উচিত । অন্তর্নিহিত প্রবাহ কম নিরাপদ এবং এটি ব্যবহার করা দৃঢ়ভাবে নিরুৎসাহিত করা হয়।
এই প্রদানকারীর একটি নাম দিন. যে প্রোভাইডার আইডি তৈরি হয়েছে তা নোট করুন: oidc.example-provider
মত কিছু। আপনি যখন আপনার অ্যাপে সাইন-ইন কোড যোগ করবেন তখন আপনার এই আইডির প্রয়োজন হবে।
আপনার ক্লায়েন্ট আইডি এবং ক্লায়েন্ট সিক্রেট এবং আপনার প্রদানকারীর ইস্যুকারী স্ট্রিং উল্লেখ করুন। এই মানগুলি অবশ্যই আপনার প্রদানকারীর দ্বারা নির্ধারিত মানগুলির সাথে হুবহু মেলে৷
আপনার পরিবর্তন সংরক্ষণ করুন.
Firebase SDK দিয়ে সাইন-ইন ফ্লো পরিচালনা করুন
আপনার OIDC প্রদানকারী ব্যবহার করে Firebase-এর মাধ্যমে আপনার ব্যবহারকারীদের প্রমাণীকরণ করার সবচেয়ে সহজ উপায় হল Firebase SDK-এর মাধ্যমে সম্পূর্ণ সাইন-ইন প্রবাহ পরিচালনা করা।
Firebase JavaScript SDK দিয়ে সাইন-ইন প্রবাহ পরিচালনা করতে, এই ধাপগুলি অনুসরণ করুন:
Firebase কনসোলে আপনি যে প্রোভাইডার আইডি পেয়েছেন সেটি ব্যবহার করে একটি OAuthProvider
এর একটি উদাহরণ তৈরি করুন।
Web
import { OAuthProvider } from "firebase/auth";
const provider = new OAuthProvider('oidc.example-provider');
Web
var provider = new firebase.auth.OAuthProvider('oidc.example-provider');
ঐচ্ছিক : অতিরিক্ত কাস্টম OAuth প্যারামিটার নির্দিষ্ট করুন যা আপনি OAuth অনুরোধের সাথে পাঠাতে চান।
Web
provider.setCustomParameters({
// Target specific email with login hint.
login_hint: 'user@example.com'
});
Web
provider.setCustomParameters({
// Target specific email with login hint.
login_hint: 'user@example.com'
});
এটি সমর্থন করে এমন পরামিতিগুলির জন্য আপনার প্রদানকারীর সাথে যোগাযোগ করুন। মনে রাখবেন যে আপনি setCustomParameters
দিয়ে Firebase-প্রয়োজনীয় প্যারামিটার পাস করতে পারবেন না। এই প্যারামিটারগুলি হল client_id
, response_type
, redirect_uri
, state
, scope
এবং response_mode
।
ঐচ্ছিক : মৌলিক প্রোফাইলের বাইরে অতিরিক্ত OAuth 2.0 স্কোপ নির্দিষ্ট করুন যা আপনি প্রমাণীকরণ প্রদানকারীর কাছ থেকে অনুরোধ করতে চান।
Web
provider.addScope('mail.read');
provider.addScope('calendars.read');
Web
provider.addScope('mail.read');
provider.addScope('calendars.read');
এটি সমর্থন করে এমন সুযোগগুলির জন্য আপনার প্রদানকারীর সাথে যোগাযোগ করুন৷
OAuth প্রদানকারী অবজেক্ট ব্যবহার করে Firebase দিয়ে প্রমাণীকরণ করুন।
আপনি হয় ব্যবহারকারীকে প্রদানকারীর সাইন-ইন পৃষ্ঠায় পুনঃনির্দেশ করতে পারেন অথবা একটি পপ-আপ ব্রাউজার উইন্ডোতে সাইন-ইন পৃষ্ঠা খুলতে পারেন৷
পুনঃনির্দেশিত প্রবাহ
signInWithRedirect()
কল করে প্রদানকারীর সাইন-ইন পৃষ্ঠায় পুনঃনির্দেশ করুন :
Web
import { getAuth, signInWithRedirect } from "firebase/auth";
const auth = getAuth();
signInWithRedirect(auth, provider);
Web
firebase.auth().signInWithRedirect(provider);
ব্যবহারকারী সাইন-ইন সম্পূর্ণ করে আপনার অ্যাপে ফিরে আসার পরে, আপনি getRedirectResult()
কল করে সাইন-ইন ফলাফল পেতে পারেন।
Web
import { getAuth, getRedirectResult, OAuthProvider } from "firebase/auth";
const auth = getAuth();
getRedirectResult(auth)
.then((result) => {
// User is signed in.
// IdP data available in result.additionalUserInfo.profile.
// Get the OAuth access token and ID Token
const credential = OAuthProvider.credentialFromResult(result);
const accessToken = credential.accessToken;
const idToken = credential.idToken;
})
.catch((error) => {
// Handle error.
});
Web
firebase.auth().getRedirectResult()
.then((result) => {
// IdP data available in result.additionalUserInfo.profile.
// ...
/** @type {firebase.auth.OAuthCredential} */
var credential = result.credential;
// OAuth access and id tokens can also be retrieved:
var accessToken = credential.accessToken;
var idToken = credential.idToken;
})
.catch((error) => {
// Handle error.
});
পপ-আপ প্রবাহ
Web
import { getAuth, signInWithPopup, OAuthProvider } from "firebase/auth";
const auth = getAuth();
signInWithPopup(auth, provider)
.then((result) => {
// User is signed in.
// IdP data available using getAdditionalUserInfo(result)
// Get the OAuth access token and ID Token
const credential = OAuthProvider.credentialFromResult(result);
const accessToken = credential.accessToken;
const idToken = credential.idToken;
})
.catch((error) => {
// Handle error.
});
Web
firebase.auth().signInWithPopup(provider)
.then((result) => {
// IdP data available in result.additionalUserInfo.profile.
// ...
/** @type {firebase.auth.OAuthCredential} */
var credential = result.credential;
// OAuth access and id tokens can also be retrieved:
var accessToken = credential.accessToken;
var idToken = credential.idToken;
})
.catch((error) => {
// Handle error.
});
যদিও উপরের উদাহরণগুলি সাইন-ইন প্রবাহের উপর ফোকাস করে, আপনি linkWithRedirect()
এবং linkWithPopup()
ব্যবহার করে একটি OIDC প্রদানকারীকে একটি বিদ্যমান ব্যবহারকারীর সাথে লিঙ্ক করতে একই প্যাটার্ন ব্যবহার করতে পারেন এবং reauthenticateWithRedirect()
এবং reauthenticateWithPopup()
ব্যবহার করে একজন ব্যবহারকারীকে পুনরায় প্রমাণীকরণ করতে পারেন, যা সাম্প্রতিক লগইন প্রয়োজন এমন সংবেদনশীল ক্রিয়াকলাপের জন্য নতুন শংসাপত্র পুনরুদ্ধার করতে ব্যবহার করা যেতে পারে।
সাইন-ইন প্রবাহ ম্যানুয়ালি পরিচালনা করুন
আপনি যদি ইতিমধ্যেই আপনার অ্যাপে OpenID Connect সাইন-ইন ফ্লো প্রয়োগ করে থাকেন, তাহলে Firebase-এর সাথে প্রমাণীকরণ করতে আপনি আইডি টোকেনটি সরাসরি ব্যবহার করতে পারেন:
Web
import { getAuth, signInWithCredential, OAuthProvider } from "firebase/auth";
const provider = new OAuthProvider("oidc.example-provider");
const credential = provider.credential({
idToken: idToken,
});
signInWithCredential(getAuth(), credential)
.then((result) => {
// User is signed in.
// IdP data available in result.additionalUserInfo.profile.
// Get the OAuth access token and ID Token
const credential = OAuthProvider.credentialFromResult(result);
const accessToken = credential.accessToken;
const idToken = credential.idToken;
})
.catch((error) => {
// Handle error.
});
Web
const provider = new OAuthProvider("oidc.example-provider");
const credential = provider.credential({
idToken: idToken,
});
firebase.auth().signInWithCredential(credential)
.then((result) => {
// User is signed in.
// IdP data available in result.additionalUserInfo.profile.
// Get the OAuth access token and ID Token
const credential = OAuthProvider.credentialFromResult(result);
const accessToken = credential.accessToken;
const idToken = credential.idToken;
})
.catch((error) => {
// Handle error.
});
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-08 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-08-08 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["If you've upgraded to Firebase Authentication with Identity Platform, you can authenticate your users with\nFirebase using the OpenID Connect (OIDC) compliant provider of your choice. This\nmakes it possible to use identity providers not natively supported by Firebase.\n\nBefore you begin\n\nTo sign in users using an OIDC provider, you must first collect some information\nfrom the provider:\n\n- **Client ID** : A string unique to the provider that identifies your app. Your\n provider might assign you a different client ID for each platform you support.\n This is one of the values of the `aud` claim in ID tokens issued by your\n provider.\n\n- **Client secret** : A secret string that the provider uses to confirm ownership\n of a client ID. For every client ID, you will need a matching client secret.\n (This value is required only if you're using the *auth code flow*, which is\n strongly recommended.)\n\n- **Issuer** : A string that identifies your provider. This value must be a URL\n that, when appended with `/.well-known/openid-configuration`, is the location\n of the provider's OIDC discovery document. For example, if the issuer is\n `https://auth.example.com`, the discovery document must be available at\n `https://auth.example.com/.well-known/openid-configuration`.\n\nAfter you have the above information, enable OpenID Connect as a sign-in\nprovider for your Firebase project:\n\n1. [Add Firebase to your JavaScript project](/docs/web/setup).\n\n2. If you haven't upgraded to Firebase Authentication with Identity Platform, do so. OpenID Connect authentication\n is only available in upgraded projects.\n\n3. On the [**Sign-in providers**](//console.firebase.google.com/project/_/authentication/providers)\n page of the Firebase console, click **Add new provider** , and then click\n **OpenID Connect**.\n\n4. Select whether you will be using the *authorization code flow* or the\n *implicit grant flow*.\n\n **You should use always the code flow if your provider supports it**. The\n implicit flow is less secure and using it is strongly discouraged.\n5. Give a name to this provider. Note the provider ID that's generated:\n something like `oidc.example-provider`. You'll need this ID when you add\n sign-in code to your app.\n\n6. Specify your client ID and client secret, and your provider's issuer string.\n These values must exactly match the values your provider assigned to you.\n\n7. Save your changes.\n\nHandle the sign-in flow with the Firebase SDK\n\nThe easiest way to authenticate your users with Firebase using your OIDC\nprovider is to handle the entire sign-in flow with the Firebase SDK.\n\nTo handle the sign-in flow with the Firebase JavaScript SDK, follow these\nsteps:\n\n1. Create an instance of an `OAuthProvider` using the provider ID you got in\n the Firebase console.\n\n Web \n\n import { OAuthProvider } from \"firebase/auth\";\n\n const provider = new OAuthProvider('oidc.example-provider');\n\n Web \n\n var provider = new firebase.auth.OAuthProvider('oidc.example-provider');\n\n2. **Optional**: Specify additional custom OAuth parameters that you want to\n send with the OAuth request.\n\n Web \n\n provider.setCustomParameters({\n // Target specific email with login hint.\n login_hint: 'user@example.com'\n });\n\n Web \n\n provider.setCustomParameters({\n // Target specific email with login hint.\n login_hint: 'user@example.com'\n });\n\n Check with your provider for the parameters it supports.\n Note that you can't pass Firebase-required parameters with\n `setCustomParameters`. These parameters are `client_id`,\n `response_type`, `redirect_uri`, `state`, `scope` and\n `response_mode`.\n3. **Optional**: Specify additional OAuth 2.0 scopes beyond basic profile that\n you want to request from the authentication provider.\n\n Web \n\n provider.addScope('mail.read');\n provider.addScope('calendars.read');\n\n Web \n\n provider.addScope('mail.read');\n provider.addScope('calendars.read');\n\n Check with your provider for the scopes it supports.\n4. Authenticate with Firebase using the OAuth provider object.\n\n You can either redirect the user to the provider's sign-in page or open the\n sign-in page in a pop-up browser window.\n\n **Redirect flow**\n\n Redirect to the provider sign-in page by calling `signInWithRedirect()`: \n\n Web \n\n import { getAuth, signInWithRedirect } from \"firebase/auth\";\n\n const auth = getAuth();\n signInWithRedirect(auth, provider);\n\n Web \n\n firebase.auth().signInWithRedirect(provider);\n\n After the user completes sign-in and returns to your app, you can obtain the\n sign-in result by calling `getRedirectResult()`. \n\n Web \n\n import { getAuth, getRedirectResult, OAuthProvider } from \"firebase/auth\";\n\n const auth = getAuth();\n getRedirectResult(auth)\n .then((result) =\u003e {\n // User is signed in.\n // IdP data available in result.additionalUserInfo.profile.\n\n // Get the OAuth access token and ID Token\n const credential = OAuthProvider.credentialFromResult(result);\n const accessToken = credential.accessToken;\n const idToken = credential.idToken;\n })\n .catch((error) =\u003e {\n // Handle error.\n });\n\n Web \n\n firebase.auth().getRedirectResult()\n .then((result) =\u003e {\n // IdP data available in result.additionalUserInfo.profile.\n // ...\n\n /** @type {firebase.auth.OAuthCredential} */\n var credential = result.credential;\n\n // OAuth access and id tokens can also be retrieved:\n var accessToken = credential.accessToken;\n var idToken = credential.idToken;\n })\n .catch((error) =\u003e {\n // Handle error.\n });\n\n **Pop-up flow** \n\n Web \n\n import { getAuth, signInWithPopup, OAuthProvider } from \"firebase/auth\";\n\n const auth = getAuth();\n signInWithPopup(auth, provider)\n .then((result) =\u003e {\n // User is signed in.\n // IdP data available using getAdditionalUserInfo(result)\n\n // Get the OAuth access token and ID Token\n const credential = OAuthProvider.credentialFromResult(result);\n const accessToken = credential.accessToken;\n const idToken = credential.idToken;\n })\n .catch((error) =\u003e {\n // Handle error.\n });\n\n Web \n\n firebase.auth().signInWithPopup(provider)\n .then((result) =\u003e {\n // IdP data available in result.additionalUserInfo.profile.\n // ...\n\n /** @type {firebase.auth.OAuthCredential} */\n var credential = result.credential;\n\n // OAuth access and id tokens can also be retrieved:\n var accessToken = credential.accessToken;\n var idToken = credential.idToken;\n })\n .catch((error) =\u003e {\n // Handle error.\n });\n\n5. While the above examples focus on sign-in flows, you can use the same\n pattern to link an OIDC provider to an existing user using\n `linkWithRedirect()` and `linkWithPopup()`, and re-authenticate a user with\n `reauthenticateWithRedirect()` and `reauthenticateWithPopup()`, which can be\n used to retrieve fresh credentials for sensitive operations that require\n recent login.\n\nHandle the sign-in flow manually\n\nIf you've already implemented the OpenID Connect sign-in flow in your app, you\ncan use the ID token directly to authenticate with Firebase: \n\nWeb \n\n import { getAuth, signInWithCredential, OAuthProvider } from \"firebase/auth\";\n\n const provider = new OAuthProvider(\"oidc.example-provider\");\n const credential = provider.credential({\n idToken: idToken,\n });\n signInWithCredential(getAuth(), credential)\n .then((result) =\u003e {\n // User is signed in.\n // IdP data available in result.additionalUserInfo.profile.\n\n // Get the OAuth access token and ID Token\n const credential = OAuthProvider.credentialFromResult(result);\n const accessToken = credential.accessToken;\n const idToken = credential.idToken;\n })\n .catch((error) =\u003e {\n // Handle error.\n });\n\nWeb \n\n const provider = new OAuthProvider(\"oidc.example-provider\");\n const credential = provider.credential({\n idToken: idToken,\n });\n firebase.auth().signInWithCredential(credential)\n .then((result) =\u003e {\n // User is signed in.\n // IdP data available in result.additionalUserInfo.profile.\n\n // Get the OAuth access token and ID Token\n const credential = OAuthProvider.credentialFromResult(result);\n const accessToken = credential.accessToken;\n const idToken = credential.idToken;\n })\n .catch((error) =\u003e {\n // Handle error.\n });"]]