पसंद के मुताबिक ऐप्लिकेशन जांच की सेवा देने वाली कंपनी लागू करें
संग्रह की मदद से व्यवस्थित रहें
अपनी प्राथमिकताओं के आधार पर, कॉन्टेंट को सेव करें और कैटगरी में बांटें.
App Check में कई प्रोवाइडर के लिए पहले से मौजूद सहायता शामिल है: Apple प्लैटफ़ॉर्म पर DeviceCheck और App Attest, Android पर Play Integrity, और वेब ऐप्लिकेशन में reCAPTCHA Enterprise (खास जानकारी). ये ऐसे जाने-माने प्रोवाइडर हैं जो ज़्यादातर डेवलपर की ज़रूरतों को पूरा करते हैं. हालांकि, आपके पास अपनी पसंद के मुताबिक App Check प्रोवाइडर को लागू करने का विकल्प भी होता है. कस्टम प्रोवाइडर का इस्तेमाल करना तब ज़रूरी होता है, जब:
आपको साथ में आए टूल के अलावा, किसी और टूल का इस्तेमाल करना है.
आपको बिल्ट-इन प्रोवाइडर का इस्तेमाल ऐसे तरीकों से करना है जिनके लिए सहायता उपलब्ध नहीं है.
आपको Apple, Android, और वेब के अलावा अन्य प्लैटफ़ॉर्म का इस्तेमाल करने वाले डिवाइसों की पुष्टि करनी हो. उदाहरण के लिए, डेस्कटॉप ओएस या इंटरनेट ऑफ़ थिंग्स (आईओटी) डिवाइसों के लिए App Check प्रोवाइडर बनाए जा सकते हैं.
आपको किसी भी प्लैटफ़ॉर्म पर, पुष्टि करने के अपने तरीके लागू करने हों.
खास जानकारी
कस्टम App Check प्रोवाइडर को लागू करने के लिए, आपको एक सुरक्षित बैकएंड एनवायरमेंट की ज़रूरत होगी. यह Node.js Firebase Admin SDK को चला सकता है.
यह Cloud Functions, Cloud Run जैसे कंटेनर प्लैटफ़ॉर्म या आपका अपना सर्वर हो सकता है.
इस एनवायरमेंट से, आपको नेटवर्क पर ऐक्सेस की जा सकने वाली एक ऐसी सेवा देनी होगी जो आपके ऐप्लिकेशन क्लाइंट से, पुष्टि करने का सबूत हासिल करती है. साथ ही, अगर पुष्टि करने का सबूत, पुष्टि करने के आपके आकलन को पूरा करता है, तो वह App Check टोकन वापस भेजती है. पुष्टि करने के लिए इस्तेमाल किए जाने वाले इंडिकेटर, इस बात पर निर्भर करेंगे कि आपने सेवा देने वाले किस तीसरे पक्ष का इस्तेमाल किया है. अगर आपने कस्टम लॉजिक लागू किया है, तो इंडिकेटर आपके बनाए हुए होंगे.
आम तौर पर, इस सेवा को REST या gRPC एंडपॉइंट के तौर पर दिखाया जाता है. हालांकि, यह जानकारी आपके हिसाब से तय होती है.
टोकन हासिल करने का एंडपॉइंट बनाना
Admin SDK को इंस्टॉल और शुरू करें.
नेटवर्क से ऐक्सेस किया जा सकने वाला ऐसा एंडपॉइंट बनाएं जो आपके क्लाइंट से पुष्टि करने का डेटा पा सके. उदाहरण के लिए, Cloud Functions का इस्तेमाल करके:
// Create endpoint at https://example-app.cloudfunctions.net/fetchAppCheckToken
exports.fetchAppCheckToken = functions.https.onRequest((request, response) => {
// ...
});
एंडपॉइंट लॉजिक में, पुष्टि करने के लिए ज़रूरी डेटा का आकलन करने की सुविधा जोड़ें. यह आपके कस्टम App Check प्रोवाइडर का मुख्य लॉजिक है. इसे आपको खुद लिखना होगा.
अगर आपको लगता है कि क्लाइंट असली है, तो Admin SDK का इस्तेमाल करके, App Check टोकन बनाएं. इसके बाद, इसे और इसके खत्म होने का समय क्लाइंट को वापस भेजें:
const admin = require('firebase-admin');
admin.initializeApp();
// ...
admin.appCheck().createToken(appId)
.then(function (appCheckToken) {
// Token expires in an hour.
const expiresAt = Math.floor(Date.now() / 1000) + 60 * 60;
// Return appCheckToken and expiresAt to the client.
})
.catch(function (err) {
console.error('Unable to create App Check token.');
console.error(err);
});
अगर क्लाइंट की पुष्टि नहीं की जा सकती, तो गड़बड़ी का मैसेज दिखाएं. उदाहरण के लिए, एचटीटीपी 403 गड़बड़ी का मैसेज दिखाएं.
ज़रूरी नहीं: अपने कस्टम प्रोवाइडर की ओर से जारी किए गए App Check टोकन के लिए, टाइम-टू-लाइव (टीटीएल) सेट करें. इसके लिए, createToken()
को AppCheckTokenOptions
ऑब्जेक्ट पास करें. टीटीएल को 30 मिनट से लेकर सात दिनों के बीच की किसी भी वैल्यू पर सेट किया जा सकता है. इस वैल्यू को सेट करते समय, इन बातों का ध्यान रखें:
- सुरक्षा: टीटीएल कम होने पर, सुरक्षा बेहतर होती है. ऐसा इसलिए, क्योंकि इससे उस समयावधि में कमी आती है जिसमें हमलावर, लीक हुए या इंटरसेप्ट किए गए टोकन का गलत इस्तेमाल कर सकता है.
- परफ़ॉर्मेंस: टीटीएल कम होने का मतलब है कि आपका ऐप्लिकेशन, पुष्टि करने की प्रोसेस को ज़्यादा बार करेगा. ऐप्लिकेशन की पुष्टि करने की प्रोसेस से, नेटवर्क अनुरोधों में हर बार कुछ समय लगता है. इसलिए, टीटीएल कम होने से आपके ऐप्लिकेशन की परफ़ॉर्मेंस पर असर पड़ सकता है.
डिफ़ॉल्ट टीटीएल एक घंटे का होता है, जो ज़्यादातर ऐप्लिकेशन के लिए सही है.
अगले चरण
आपने कस्टम प्रोवाइडर के सर्वर-साइड लॉजिक को लागू कर दिया है. अब Apple, Android, और वेब क्लाइंट से इसका इस्तेमाल करने का तरीका जानें.
जब तक कुछ अलग से न बताया जाए, तब तक इस पेज की सामग्री को Creative Commons Attribution 4.0 License के तहत और कोड के नमूनों को Apache 2.0 License के तहत लाइसेंस मिला है. ज़्यादा जानकारी के लिए, Google Developers साइट नीतियां देखें. Oracle और/या इससे जुड़ी हुई कंपनियों का, Java एक रजिस्टर किया हुआ ट्रेडमार्क है.
आखिरी बार 2025-08-23 (UTC) को अपडेट किया गया.
[null,null,["आखिरी बार 2025-08-23 (UTC) को अपडेट किया गया."],[],[],null,["# Implement a custom App Check provider\n\nApp Check has built-in support for several providers: DeviceCheck and App\nAttest on Apple platforms, Play Integrity on Android, and reCAPTCHA Enterprise\nin web apps ([overview](/docs/app-check)). These are well-understood providers\nthat should meet the needs of most developers. You can, however, also implement\nyour own custom App Check providers. Using a custom provider is necessary\nwhen:\n\n- You want to use a provider other than the built-in ones.\n\n- You want to use the built-in providers in unsupported ways.\n\n- You want to verify devices using platforms other than Apple, Android, and the\n web. For example, you could create App Check providers for desktop OSes or\n Internet-of-Things devices.\n\n- You want to implement your own verification techniques on any platform.\n\nOverview\n--------\n\nTo implement a custom App Check provider, you need a secure backend\nenvironment that can run the Node.js [Firebase Admin SDK](/docs/admin/setup).\nThis can be Cloud Functions, a container platform such as\n[Cloud Run](https://cloud.google.com/run), or your own server.\n\nFrom this environment, you will provide a network-accessible service that\nreceives proof of authenticity from your app clients, and---if the proof of\nauthenticity passes your authenticity assessment---returns an App Check\ntoken. The specific indicators you use as proof of authenticity will depend on\neither the third-party provider you're using, or the indicators of your own\ninvention, if you're implementing custom logic.\n\nUsually, you expose this service as a REST or gRPC endpoint, but this detail is\nup to you.\n\nCreate the token acquisition endpoint\n-------------------------------------\n\n1. [Install and initialize the Admin SDK](/docs/admin/setup).\n\n2. Create a network-accessible endpoint that can receive authenticity data from\n your clients. For example, using Cloud Functions:\n\n // Create endpoint at https://example-app.cloudfunctions.net/fetchAppCheckToken\n exports.fetchAppCheckToken = functions.https.onRequest((request, response) =\u003e {\n // ...\n });\n\n3. Add to the endpoint logic that assesses the authenticity data. This is the\n core logic of your custom App Check provider, which you will need to\n write yourself.\n\n4. If you determine the client to be authentic, use the Admin SDK to mint\n an App Check token and return it and its expiration time to the client:\n\n const admin = require('firebase-admin');\n admin.initializeApp();\n\n // ...\n\n admin.appCheck().createToken(appId)\n .then(function (appCheckToken) {\n // Token expires in an hour.\n const expiresAt = Math.floor(Date.now() / 1000) + 60 * 60;\n\n // Return appCheckToken and expiresAt to the client.\n })\n .catch(function (err) {\n console.error('Unable to create App Check token.');\n console.error(err);\n });\n\n | **Note:** If you encounter a token signing error while creating a new token, make sure your service account has the required permissions. See the [Admin SDK troubleshooting guide](/docs/auth/admin/create-custom-tokens#troubleshooting).\n\n If you can't verify the client's authenticity, return an error (for example,\n return an HTTP 403 error).\n5. **Optional** : Set the time-to-live (TTL) for App Check tokens issued by\n your custom provider by passing an `AppCheckTokenOptions` object to\n `createToken()`. You can set the TTL to any value between 30 minutes and 7\n days. When setting this value, be aware of the following tradeoffs:\n\n - Security: Shorter TTLs provide stronger security, because it reduces the window in which a leaked or intercepted token can be abused by an attacker.\n - Performance: Shorter TTLs mean your app will perform attestation more frequently. Because the app attestation process adds latency to network requests every time it's performed, a short TTL can impact the performance of your app.\n\n The default TTL of 1 hour is reasonable for most apps.\n\nNext steps\n----------\n\nNow that you've implemented your custom provider's server-side logic, learn how\nto use it from your [Apple](/docs/app-check/ios/custom-provider),\n[Android](/docs/app-check/android/custom-provider), and [web](/docs/app-check/web/custom-provider) clients."]]