অ্যাপ চেক ইন ওয়েব অ্যাপের মাধ্যমে কাস্টম ব্যাকএন্ড সংস্থানগুলিকে সুরক্ষিত করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
আপনি আপনার অ্যাপের জন্য নন-Google কাস্টম ব্যাকএন্ড রিসোর্স, যেমন আপনার নিজের স্ব-হোস্ট করা ব্যাকএন্ড রক্ষা করতে App Check ব্যবহার করতে পারেন। এটি করার জন্য, আপনাকে নিম্নলিখিত উভয়টি করতে হবে:
আপনি শুরু করার আগে
reCAPTCHA এন্টারপ্রাইজ প্রদানকারী বা একটি কাস্টম প্রদানকারী ব্যবহার করে আপনার অ্যাপে App Check যোগ করুন।
ব্যাকএন্ড অনুরোধ সহ App Check টোকেন পাঠান
আপনার অ্যাপ ক্লায়েন্টে, প্রতিটি অনুরোধের আগে, appCheck().getToken()
সহ একটি বৈধ, মেয়াদ শেষ না হওয়া App Check টোকেন পান। App Check লাইব্রেরি প্রয়োজনে টোকেন রিফ্রেশ করবে।
একবার আপনার কাছে একটি বৈধ টোকেন হয়ে গেলে, আপনার ব্যাকএন্ডে অনুরোধ সহ এটি পাঠান। আপনি কীভাবে এটি সম্পন্ন করবেন তার সুনির্দিষ্ট বিষয়গুলি আপনার উপর নির্ভর করে, কিন্তু ক্যোয়ারী প্যারামিটার সহ URL-এর অংশ হিসাবে App Check টোকেনগুলি পাঠাবেন না , কারণ এটি তাদের দুর্ঘটনাজনিত ফাঁস এবং বাধার জন্য ঝুঁকিপূর্ণ করে তোলে৷ নিম্নলিখিত উদাহরণটি একটি কাস্টম HTTP শিরোনামে টোকেন পাঠায়, যা প্রস্তাবিত পদ্ধতি।
Web
import { initializeAppCheck, getToken } from 'firebase/app-check';
const appCheck = initializeAppCheck(
app,
{ provider: provider } // ReCaptchaV3Provider or CustomProvider
);
const callApiWithAppCheckExample = async () => {
let appCheckTokenResponse;
try {
appCheckTokenResponse = await getToken(appCheck, /* forceRefresh= */ false);
} catch (err) {
// Handle any errors if the token was not retrieved.
return;
}
// Include the App Check token with requests to your server.
const apiResponse = await fetch('https://yourbackend.example.com/yourApiEndpoint', {
headers: {
'X-Firebase-AppCheck': appCheckTokenResponse.token,
}
});
// Handle response from your backend.
};
Web
const callApiWithAppCheckExample = async () => {
let appCheckTokenResponse;
try {
appCheckTokenResponse = await firebase.appCheck().getToken(/* forceRefresh= */ false);
} catch (err) {
// Handle any errors if the token was not retrieved.
return;
}
// Include the App Check token with requests to your server.
const apiResponse = await fetch('https://yourbackend.example.com/yourApiEndpoint', {
headers: {
'X-Firebase-AppCheck': appCheckTokenResponse.token,
}
});
// Handle response from your backend.
};
রিপ্লে সুরক্ষা (বিটা)
আপনি রিপ্লে সুরক্ষা সক্ষম করেছেন এমন একটি এন্ডপয়েন্টে অনুরোধ করার সময়, getToken getLimitedUseToken()
getToken()
ব্যবহার করে একটি টোকেন অর্জন করুন:
import { getLimitedUseToken } from "firebase/app-check";
// ...
appCheckTokenResponse = await getLimitedUseToken(appCheck);
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-22 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-08-22 UTC-তে শেষবার আপডেট করা হয়েছে।"],[],[],null,["You can use App Check to protect non-Google custom backend resources for\nyour app, like your own self-hosted backend. To do so, you'll need to do both of\nthe following:\n\n- Modify your app client to send an App Check token along with each request to your backend, as described on this page.\n- Modify your backend to require a valid App Check token with every request, as described in [Verify App Check tokens from a custom backend](/docs/app-check/custom-resource-backend).\n\nBefore you begin\n\nAdd App Check to your app, using either the\n[reCAPTCHA Enterprise provider](/docs/app-check/web/recaptcha-enterprise-provider)\nor a [custom provider](/docs/app-check/web/custom-provider).\n\nSend App Check tokens with backend requests\n\nIn your app client, before each request, get a valid, unexpired, App Check\ntoken with `appCheck().getToken()`. The App Check library will refresh the\ntoken if necessary.\n\nOnce you have a valid token, send it along with the request to your backend. The\nspecifics of how you accomplish this are up to you, but *don't send\nApp Check tokens as part of URLs*, including in query parameters, as this\nmakes them vulnerable to accidental leakage and interception. The following\nexample sends the token in a custom HTTP header, which is the recommended\napproach. \n\nWeb \n\n```javascript\nimport { initializeAppCheck, getToken } from 'firebase/app-check';\n\nconst appCheck = initializeAppCheck(\n app,\n { provider: provider } // ReCaptchaV3Provider or CustomProvider\n);\n\nconst callApiWithAppCheckExample = async () =\u003e {\n let appCheckTokenResponse;\n try {\n appCheckTokenResponse = await getToken(appCheck, /* forceRefresh= */ false);\n } catch (err) {\n // Handle any errors if the token was not retrieved.\n return;\n }\n\n // Include the App Check token with requests to your server.\n const apiResponse = await fetch('https://yourbackend.example.com/yourApiEndpoint', {\n headers: {\n 'X-Firebase-AppCheck': appCheckTokenResponse.token,\n }\n });\n\n // Handle response from your backend.\n};https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/snippets/appcheck-next/index/appcheck_nonfirebase.js#L8-L32\n```\n\nWeb \n\n```javascript\nconst callApiWithAppCheckExample = async () =\u003e {\n let appCheckTokenResponse;\n try {\n appCheckTokenResponse = await firebase.appCheck().getToken(/* forceRefresh= */ false);\n } catch (err) {\n // Handle any errors if the token was not retrieved.\n return;\n }\n\n // Include the App Check token with requests to your server.\n const apiResponse = await fetch('https://yourbackend.example.com/yourApiEndpoint', {\n headers: {\n 'X-Firebase-AppCheck': appCheckTokenResponse.token,\n }\n });\n\n // Handle response from your backend.\n};https://github.com/firebase/snippets-web/blob/467eaa165dcbd9b3ab15711e76fa52237ba37f8b/appcheck/index.js#L68-L85\n```\n\nReplay protection (beta)\n\nWhen making a request to an endpoint for which you've enabled\n[replay protection](/docs/app-check/custom-resource-backend#replay-protection),\nacquire a token using `getLimitedUseToken()` instead of `getToken()`: \n\n import { getLimitedUseToken } from \"firebase/app-check\";\n\n // ...\n\n appCheckTokenResponse = await getLimitedUseToken(appCheck);"]]