لضمان تضمين طلبات الخلفية لرمز مميّز صالح وغير منتهية صلاحيته من App Check،
عليك إضافة استدعاء إلى getToken() قبل كل طلب. ستعيد مكتبة App Check تحميل الرمز المميز إذا لزم الأمر.
بعد الحصول على رمز مميّز صالح، أرسِله مع الطلب إلى الخلفية. يعود إليك تحديد الطريقة التي ستتّبعها، ولكن لا ترسِل رموز App Check المميزة كجزء من عناوين URL، بما في ذلك في مَعلمات طلب البحث، لأنّ ذلك يعرّضها لخطر التسريب والاعتراض غير المقصودَين. ويتمثّل الأسلوب المقترَح في إرسال الرمز المميّز في عنوان HTTP مخصّص.
على سبيل المثال:
voidcallApiExample()async{finalappCheckToken=awaitFirebaseAppCheck.instance.getToken();if(appCheckToken!=null){finalresponse=awaithttp.get(Uri.parse("https://yourbackend.example.com/yourExampleEndpoint"),headers:{"X-Firebase-AppCheck":appCheckToken},);}else{// Error: couldn't get an App Check token.}}
تاريخ التعديل الأخير: 2025-08-23 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-23 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["\u003cbr /\u003e\n\nYou 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 the [default providers](/docs/app-check/flutter/default-providers).\n\nSend App Check tokens with backend requests\n\nTo ensure your backend requests include a valid, unexpired, App Check token,\nprecede each request with a call to `getToken()`. The App Check library\nwill refresh the token 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 recommended\napproach is to send the token in a custom HTTP header.\n\nFor example: \n\n void callApiExample() async {\n final appCheckToken = await FirebaseAppCheck.instance.getToken();\n if (appCheckToken != null) {\n final response = await http.get(\n Uri.parse(\"https://yourbackend.example.com/yourExampleEndpoint\"),\n headers: {\"X-Firebase-AppCheck\": appCheckToken},\n );\n } else {\n // Error: couldn't get an App Check token.\n }\n }"]]