Android'de Uygulama Kontrolü ile özel arka uç kaynaklarını koruma
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Uygulamanız için Google dışı özel arka uç kaynaklarını (ör. kendi kendine barındırılan arka ucunuz) korumak üzere App Check kullanabilirsiniz. Bunun için aşağıdakilerin ikisini de yapmanız gerekir:
Uygulama istemcinizi, bu sayfada açıklandığı şekilde, arka uçunuza gönderilen her istekle birlikte bir App Check jetonu gönderecek şekilde değiştirin.
Arka uç isteklerinizin geçerli, süresi dolmamış bir App Check jetonu içerdiğinden emin olmak için her isteği getAppCheckToken() çağrısına sarmalayın. App Check kitaplığı gerekirse jetonu yeniler ve jetona yöntemin başarı dinleyicisinden erişebilirsiniz.
Geçerli bir jetonunuz olduğunda, istekle birlikte arka ucunuza gönderin. Bunu nasıl yapacağınız size bağlıdır ancak URL'lerin bir parçası olarak App Check jetonları göndermeyin. Bu, sorgu parametreleri de dahil olmak üzere jetonların yanlışlıkla sızdırılmasına ve saldırıya uğramasına neden olur. Jetonu özel bir HTTP üstbilgisinde göndermeniz önerilir.
Yeniden oynatma korumasını etkinleştirdiğiniz bir uç noktaya istekte bulunurken isteği getAppCheckToken() yerine getLimitedUseAppCheckToken() çağrısıyla sarmalayın:
[[["Anlaması kolay","easyToUnderstand","thumb-up"],["Sorunumu çözdü","solvedMyProblem","thumb-up"],["Diğer","otherUp","thumb-up"]],[["İhtiyacım olan bilgiler yok","missingTheInformationINeed","thumb-down"],["Çok karmaşık / çok fazla adım var","tooComplicatedTooManySteps","thumb-down"],["Güncel değil","outOfDate","thumb-down"],["Çeviri sorunu","translationIssue","thumb-down"],["Örnek veya kod sorunu","samplesCodeIssue","thumb-down"],["Diğer","otherDown","thumb-down"]],["Son güncelleme tarihi: 2025-09-03 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 default\n[Play Integrity provider](/docs/app-check/android/play-integrity-provider), or a\n[custom provider](/docs/app-check/android/custom-provider).\n\nSend App Check tokens with backend requests\n\nTo ensure your backend requests include a valid, unexpired, App Check token,\nwrap each request in a call to `getAppCheckToken()`. The App Check library\nwill refresh the token if necessary, and you can access the token in the\nmethod's success listener.\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, if you use Retrofit: \n\nKotlin \n\n```kotlin\nclass ApiWithAppCheckExample {\n interface YourExampleBackendService {\n @GET(\"yourExampleEndpoint\")\n fun exampleData(\n @Header(\"X-Firebase-AppCheck\") appCheckToken: String,\n ): Call\u003cList\u003cString\u003e\u003e\n }\n\n var yourExampleBackendService: YourExampleBackendService = Retrofit.Builder()\n .baseUrl(\"https://yourbackend.example.com/\")\n .build()\n .create(YourExampleBackendService::class.java)\n\n fun callApiExample() {\n Firebase.appCheck.getAppCheckToken(false).addOnSuccessListener { appCheckToken -\u003e\n val token = appCheckToken.token\n val apiCall = yourExampleBackendService.exampleData(token)\n // ...\n }\n }\n}https://github.com/firebase/snippets-android/blob/b694d4dbd411d31be39655f47691c3e9f3529b03/appcheck/app/src/main/java/com/google/firebase/example/appcheck/kotlin/ApiWithAppCheckExample.kt#L11-L31\n```\n\nJava \n\n```java\npublic class ApiWithAppCheckExample {\n private interface YourExampleBackendService {\n @GET(\"yourExampleEndpoint\")\n Call\u003cList\u003cString\u003e\u003e exampleData(\n @Header(\"X-Firebase-AppCheck\") String appCheckToken);\n }\n\n YourExampleBackendService yourExampleBackendService = new Retrofit.Builder()\n .baseUrl(\"https://yourbackend.example.com/\")\n .build()\n .create(YourExampleBackendService.class);\n\n public void callApiExample() {\n FirebaseAppCheck.getInstance()\n .getAppCheckToken(false)\n .addOnSuccessListener(new OnSuccessListener\u003cAppCheckToken\u003e() {\n @Override\n public void onSuccess(@NonNull AppCheckToken appCheckToken) {\n String token = appCheckToken.getToken();\n Call\u003cList\u003cString\u003e\u003e apiCall =\n yourExampleBackendService.exampleData(token);\n // ...\n }\n });\n }\n}https://github.com/firebase/snippets-android/blob/b694d4dbd411d31be39655f47691c3e9f3529b03/appcheck/app/src/main/java/com/google/firebase/example/appcheck/ApiWithAppCheckExample.java#L18-L43\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),\nwrap the request in a call to `getLimitedUseAppCheckToken()` instead of\n`getAppCheckToken()`: \n\nKotlin \n\n```kotlin\nFirebase.appCheck.limitedUseAppCheckToken.addOnSuccessListener {\n // ...\n}https://github.com/firebase/snippets-android/blob/b694d4dbd411d31be39655f47691c3e9f3529b03/appcheck/app/src/main/java/com/google/firebase/example/appcheck/kotlin/ApiWithAppCheckExample.kt#L37-L39\n```\n\nJava \n\n```java\nFirebaseAppCheck.getInstance()\n .getLimitedUseAppCheckToken().addOnSuccessListener(\n new OnSuccessListener\u003cAppCheckToken\u003e() {\n @Override\n public void onSuccess(AppCheckToken appCheckToken) {\n String token = appCheckToken.getToken();\n // ...\n }\n }\n );https://github.com/firebase/snippets-android/blob/b694d4dbd411d31be39655f47691c3e9f3529b03/appcheck/app/src/main/java/com/google/firebase/example/appcheck/ApiWithAppCheckExample.java#L49-L58\n```"]]