Firebase ML Apple uygulamanızın Cloud kimlik bilgilerini koruyun
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Apple uygulamanız Firebase ML'nın bulut API'lerinden birini kullanıyorsa uygulamanızı üretimde kullanıma sunmadan önce yetkisiz API erişimini engellemek için birkaç işlem daha yapmanız gerekir.
1. Mevcut API anahtarlarının kapsamını daraltma
Öncelikle, mevcut API anahtarlarınızı Cloud Vision API'ye erişimi engelleyecek şekilde yapılandırın:
Google Cloud konsolunun Kimlik bilgileri sayfasını açın. İstendiğinde projenizi seçin.
Listedeki her mevcut API anahtarı için düzenleme görünümünü açın.
API kısıtlamaları bölümünde Anahtarı kısıtla'yı seçin, ardından API anahtarının erişmesini istediğiniz tüm API'leri listeye ekleyin. Cloud Vision API'nin dahil edilmediğinden emin olun.
Bir API anahtarının API kısıtlamalarını yapılandırdığınızda, anahtarın erişebileceği API'leri açıkça belirtirsiniz. Varsayılan olarak, API kısıtlamaları bölümünde Anahtarı kısıtlama seçiliyken bir API anahtarı, proje için etkinleştirilmiş tüm API'lere erişmek üzere kullanılabilir.
Mevcut API anahtarlarınız artık Cloud ML hizmetlerine erişim izni vermeyecek ancak her anahtar, API kısıtlamaları listesine eklediğiniz tüm API'ler için çalışmaya devam edecek.
Gelecekte ek API'ler etkinleştirirseniz bunları ilgili API anahtarının API kısıtlamaları listesine eklemeniz gerektiğini unutmayın.
2. Firebase ML ile kullanılmak üzere yeni bir API anahtarı oluşturun.
Ardından, Firebase ML için yalnızca Cloud Vision API'ye yapılan çağrılara izin veren yeni bir API anahtarı oluşturun:
Kimlik bilgileri sayfasına dönün. Firebase projenizin seçili olduğundan emin olun.
Kimlik bilgileri oluştur > API anahtarı'nı tıklayın. Yeni API anahtarını not edin, ardından Anahtarı kısıtla'yı tıklayın.
API kısıtlamaları bölümünde Anahtarı kısıtla'yı seçin, ardından listeye yalnızca Cloud Vision API'yi ekleyin.
Bu API anahtarı yalnızca Cloud Vision API'ye erişim izni verir ve Firebase ML tarafından bulut tabanlı modellere erişmek için kullanılabilir.
Güvenliği ihlal edilmiş bir anahtarın sonuçlarını azaltmak için Cloud Vision API'nin kullanıcı başına kotasını varsayılan ayarından düşürmeniz gerekir. Bunu yapmak için:
İstekler bölümünde, Kullanıcı başına dakika başına istek sayısı kotasını uygulamanız için makul bir değere ayarlayın. Örneğin, uygulamanızda bir belgenin metnini almak için belgenin resmini yükleme işlemi yapılıyorsa kullanıcının bunu birkaç saniyede birden fazla kez yapması pek olası değildir. Bu nedenle, 30-40 kotası muhtemelen güvenli olacaktır.
Bu bağlamda "kullanıcı başına istek" ifadesinin tek bir IP adresinden gelen istekleri ifade ettiğini unutmayın. Birden fazla kullanıcının NAT'ın arkasından aynı anda uygulamanızı kullanmasını bekliyorsanız bunu göz önünde bulundurmanız gerekebilir.
4. Firebase ML API anahtarınızı kullanarak Cloud API'lerini çağırma
Son olarak, uygulamanızda Firebase ML yeni API anahtarınızı kullanacak şekilde yapılandırın.
Firebase ML API anahtarı, Cloud Vision API'ye kimliği doğrulanmamış erişime izin verdiğinden yetkisiz kullanımı ve faturalandırma hesabınıza yansıtılacak ücretleri önlemek için anahtarın gizli tutulması önemlidir. Bunu yapmak için API anahtarınızı uygulama ikili programınıza eklememeniz gerekir. Bunun yerine, uygulama çalışma zamanında bilinen iyi bir kullanıcının oturum açtığını doğrulayın ve yalnızca o zaman API anahtarını bir sunucudan alın.
Bu uygulamalara uyulsa bile API anahtarının güvenliği ihlal edilebilir. Yukarıda açıklandığı gibi API'nin kullanıcı başına kotasını azaltma, anahtar döndürme politikaları uygulama ve farklı kullanıcı gruplarına farklı anahtarlar verme gibi, güvenliği ihlal edilmiş bir anahtarın sonuçlarını azaltmaya yardımcı olacak adımlar atmanız gerekir.
Uygulamanız API anahtarını güvenli bir şekilde aldıktan sonra bir Firebase ML Cloud API'yi çağırmak istediğinizde anahtarı belirtin:
Swift
ifletcloudVisionKey=getYourApiKey(){// See note above about securing your API keyletoptions=VisionCloudDetectorOptions()options.apiKeyOverride=cloudVisionKeyletcloudDetector=Vision.vision().cloudLandmarkDetector(options:options)}
Objective-C
NSString*cloudVisionKey=[selfgetYourApiKey];// See note above about securing your API keyif(cloudVisionKey!=nil){FIRVisionCloudDetectorOptions*options=[[FIRVisionCloudDetectorOptionsalloc]init];options.APIKeyOverride=cloudVisionKey;FIRVisionCloudLandmarkDetector*landmarkDetector=[visioncloudLandmarkDetectorWithOptions:options];}
Diğer Firebase özelliklerini kullanırken uygulamanızı kullanıma sunmaya hazırlama hakkında bilgi edinmek için kullanıma sunma yapılacaklar listesine bakı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-07-25 UTC."],[],[],null,["\u003cbr /\u003e\n\nIf your Apple app uses one of Firebase ML's cloud APIs, before you launch your app\nin production, you should take some additional steps to prevent unauthorized\nAPI access.\n\n1. Reduce the scope of existing API keys\n\nFirst, configure your existing API keys to disallow access to the Cloud Vision\nAPI:\n\n1. Open the [Credentials](https://console.cloud.google.com/apis/credentials?project=_) page of the\n Google Cloud console. When prompted, select your project.\n\n2. For each existing API key in the list, open the editing view.\n\n3. In the *API restrictions* section, select **Restrict key** , then add to the\n list all of the APIs to which you want the API key to have access. Make sure\n to ***not*** include the Cloud Vision API.\n\n When you configure an API key's *API restrictions* , you are explicitly\n declaring the APIs to which the key has access. **By default, when the *API\n restrictions* section has *Don't restrict key* selected, an API key can be\n used to access any API that is enabled for the project.**\n\nNow, your existing API keys will not grant access to cloud ML services, but each\nkey will continue to work for any APIs that you added to its *API restrictions*\nlist.\n\nNote that if you enable any additional APIs in the future, you must add them to\nthe *API restrictions* list for the applicable API key.\n\n2. Create a new API key for use with Firebase ML\n\nNext, create a new API key for Firebase ML that only allows calls to the\nCloud Vision API:\n\n1. Return to the [Credentials](https://console.cloud.google.com/apis/credentials) page. Be sure your\n Firebase project is still selected.\n\n2. Click **Create credentials \\\u003e API key** . Take note of the new API key, then\n click **Restrict key**.\n\n3. In the *API restrictions* section, select **Restrict key** , then add to the\n list ***only*** the Cloud Vision API.\n\nThis API key grants access only to the Cloud Vision API and can be used by\nFirebase ML to access cloud-based models.\n\n3. Recommended: Reduce the Cloud Vision API's quota\n\nTo help mitigate the consequences of a compromised key, you should reduce the\nCloud Vision API's per-user quota from its default setting. To do so:\n\n1. Open the [Cloud Vision API Quotas](https://console.cloud.google.com/apis/api/vision.googleapis.com/quotas?project=_) page of the\n Google Cloud console. When prompted, select your project.\n\n2. In the **Requests** section, set the **Requests per minute per user** quota\n to something reasonable for your app. For example, if your app involves\n uploading a picture of a document to get back its text, it's unlikely that a\n user will do that more than once every few seconds, so a quota of 30-40\n would probably be safe.\n\n Note that in this context \"requests per user\" refers to requests from a\n single IP address. You might need to consider this if you expect multiple\n users to use your app at the same time from behind a NAT.\n\n4. Call Cloud APIs using your Firebase ML API key\n\nFinally, in your app, configure Firebase ML to use your new API key.\n\nBecause the Firebase ML API key allows unauthenticated access to the Cloud Vision\nAPI, it's important to keep the key confidential to prevent unauthorized use and\ncharges to your billing account. To do so, you should refrain from including\nyour API key in your app binary. Instead, at app runtime, verify that a known\ngood user is signed in, and only then, retrieve the API key from a server.\n\nEven when these practices are observed, it is possible for an API key to be\ncompromised. You should take steps to help mitigate the consequences of a\ncompromised key, such as reducing the API's per-user quota as described above,\nimplementing key rotation policies, and issuing different keys to different\ngroups of users.\n\nAfter your app has safely acquired the API key, when you want to call an\nFirebase ML Cloud API, specify the key: \n\nSwift \n\n if let cloudVisionKey = getYourApiKey() { // See note above about securing your API key\n let options = VisionCloudDetectorOptions()\n options.apiKeyOverride = cloudVisionKey\n let cloudDetector = Vision.vision().cloudLandmarkDetector(options: options)\n }\n\nObjective-C \n\n NSString *cloudVisionKey = [self getYourApiKey]; // See note above about securing your API key\n if (cloudVisionKey != nil) {\n FIRVisionCloudDetectorOptions *options =\n [[FIRVisionCloudDetectorOptions alloc] init];\n options.APIKeyOverride = cloudVisionKey;\n FIRVisionCloudLandmarkDetector *landmarkDetector =\n [vision cloudLandmarkDetectorWithOptions:options];\n }\n\nIn addition, you should follow the general advice in\n[Securing an API key](https://cloud.google.com/docs/authentication/api-keys#securing_an_api_key).\n\nNext steps\n\nSee the [launch checklist](/support/guides/launch-checklist) for information on\npreparing your app to launch when using other Firebase features."]]