Uygulamanıza Sunucu Tarafı Lisans Doğrulamasını Ekleme
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Kullanıcının uygulamanızın yasal bir kopyasını Google Play Store'dan satın aldığını veya indirdiğini doğrularken lisans doğrulama kontrolünü sizin kontrol ettiğiniz bir sunucuda gerçekleştirmek en iyisidir.
Bu kılavuzda, sunucu tarafı lisans doğrulamasını tamamlamayla ilgili adım adım talimatlar ve bu kontrolün yapılmasıyla ilgili bazı en iyi uygulamalar sunulmaktadır.
Sürece genel bakış
Şekil 1'de, bilgilerin uygulamanız, Google Play ve özel sunucunuz arasında nasıl aktarıldığı gösterilmektedir:
Şekil 1. Uygulamanız ile Google Play, ardından uygulamanız ve özel sunucunuz arasındaki veri akışı
Uygulamanız, belirli bir kullanıcının uygulamanızın yasal bir kopyasını satın alıp almadığını veya indirip indirmediğini öğrenmek için Google Play'e istekte bulunur.
Google Play, uygulamanıza ResponseData türünde bir nesne olan yanıt veri nesnesi göndererek yanıt verir. Bu nesne, kullanıcının uygulamanızın yasal bir kopyasını satın alıp almadığını veya indirip indirmediğini belirten imzalı bir bilgidir.
Uygulamanız, kontrol ettiğiniz bir özel sunucuya istekte bulunarak yanıt verilerinin içeriğini doğrular.
Sunucu, uygulamanıza bir durum göndererek yanıt verir ve kullanıcının, uygulamanızın yasal bir kopyasını gerçekten satın alıp almadığını veya indirip indirmediğini gösterir. Sunucu "başarılı" mesajı sağlarsa yanıtı doğrulayın ve ardından kullanıcıya lisans gerektiren kaynaklara erişim izni verin.
Yanıt verileri Google Play tarafından imzalanıp sunucunuzda kontrol edildiğinden, uygulamanızı çalıştıran cihazdaki nesneyi değiştirmenin yolu yoktur. Uygulamanız sunucuya bağımlıysa ve kaynakları yalnızca meşru kullanıcıların kullanımına sunuyorsa uygulamanız yetkisiz kullanıcılara karşı önemli ölçüde daha korunur.
Aşağıdaki bölümlerde, sunucu tarafı lisans doğrulaması gerçekleştirirken göz önünde bulundurulması gereken ek noktalar açıklanmıştır.
Tekrarlama saldırılarına karşı koruma sağlayın
Google Play'den kullanıcının lisans durumuyla ilgili bir yanıt aldıktan sonra, kullanıcı yanıt verilerini kopyalayıp birden çok kez kullanabilir veya uygulamanızın özel sunucusuna kendi isteklerini oluşturabilecek diğer kullanıcılara verebilir. Bu tür eylemler tekrar saldırısı olarak bilinir.
Kullanıcıların tekrar oynatma saldırılarını gerçekleştirme olasılığını azaltmak için uygulamanızın sunucusuna istek göndermeden önce aşağıdaki önlemleri alın:
Google Play'in yanıtı kısa süre önce oluşturduğundan emin olarak yanıt verilerindeki zaman damgasını kontrol edin.
Uygulamanızın, aynı yanıt verilerini uygulamanızın sunucusuna gönderme deneme sayısını azaltmak için sunucu isteğinizde üstel geri çekilme gibi hız sınırlandırması uygulayın.
Google Play'in özel sunucunuzdaki yanıt verilerinin içeriğini doğrulamadan önce, özel sunucunuza kimlik doğrulama tabanlı ilk bir istek gönderin. Bu ilk istekte kullanıcı kimlik bilgilerini sunucunuza gönderin ve ardından sunucunuzun bir tek seferlik veya yalnızca bir kez kullanılan bir sayı ile yanıt vermesini sağlayın. Ardından bu tek seferlik rastgele sayıyı özel sunucunuza yapılacak bir sonraki isteğinize ekleyerek lisans doğrulama verilerini isteyebilirsiniz. Tek seferlik rastgele bir değer seçmeyle ilgili ayrıntılar için uygun bir tek seferlik rastgele değer oluşturma bölümüne bakın.
Uygun bir tek seferlik rastgele değeri oluştur
Tahmin edilmesi zor bir tek seferlik rastgele değeri oluşturmak için aşağıdaki tekniklerden birini kullanın:
Kullanıcı kimliğine göre bir karma değeri oluşturun.
Kullanıcı bazında rastgele bir değer oluşturun. Bu rastgele değeri, uygulamanızın sunucusunda belirli bir kullanıcı özelliklerinin parçası olarak depolayın.
Sunucunuzdan alınan yanıt verilerini doğrulayın
Uygulama sunucusunun uygulamanıza gönderdiği yanıt verilerini incelerken, Lisans Doğrulama Kitaplığı yanıtının sahte olmadığından emin olun. Uygulama sunucusunun yanıt verilerindeki imzayı, uygulamanızın önceki adımda Google Play'den aldığı anahtarla karşılaştırarak doğrulayın.
Ayrıca, Lisans Doğrulama Kitaplığı'na (LVL) özel blokun, imzalı tek bölüm olduğunu da unutmamak gerekir. Bu nedenle, uygulama sunucunuzun yanıt verilerinde uygulamanızın güvenmesi gereken tek parça budur.
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-07-27 UTC.
[[["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-27 UTC."],[],[],null,["# Adding Server-Side License Verification to Your App\n\nWhen verifying that the user has purchased or downloaded a legitimate copy of\nyour app from the Google Play Store, it's best to perform the license\nverification check on a server that you control.\n\nThis guide presents a step-by-step process for completing server-side license\nverification and presents some best practices related to performing this check.\n\nProcess overview\n----------------\n\nFigure 1 shows how information is transferred between your app, Google Play, and\nyour private server: \n**Figure 1.** Flow of data between your app and Google Play, then between your app and your private server\n\n1. Your app makes a request to Google Play, inquiring about whether a particular user has purchased or downloaded a legitimate copy of your app.\n2. Google Play responds by sending a *response data object* , an object of type [`ResponseData`](/google/play/licensing/licensing-reference#lvl-summary), to your app. This object is a signed piece of information that states whether the user has purchased or downloaded a legitimate copy of your app.\n3. Your app makes a request to a private server that you control, verifying the contents of the response data.\n4. The server responds by sending a status to your app, indicating whether the user has indeed purchased or downloaded a legitimate copy of your app. If the server provides a \"success\" message, [verify the\n response](#verify-app-server-response) and then grant the user access to the resources that require a license.\n\nBecause the response data is signed by Google Play, then checked on your\nserver, there's no way to modify the object on the device running your app. If\nyour app relies on the server and makes resources available only to legitimate\nusers, your app is substantially more protected against unauthorized users.\n\nThe following sections provide additional considerations to keep in mind when\nperforming server-side license verification.\n\nSafeguard against replay attacks\n--------------------------------\n\nAfter receiving a response from Google Play regarding the user's license status,\nit's possible for the user to copy the response data and use it multiple times,\nor give it to other users who could then forge their own requests to your app's\nprivate server. This sort of action is known as a *replay attack*.\n\nTo reduce the likelihood of users performing replay attacks successfully, take\nthe following measures before sending a request to your app's server:\n\n- Check the timestamp that's included in the response data, making sure that\n Google Play generated the response recently.\n\n | **Note:** You can increase the allowed difference between the response data's timestamp and the current time based on how long users should be able to interact with license-bound resources after they deactivate their license.\n- Perform rate-limiting on your server request, such as exponential backoff, to\n reduce the number of times that your app attempts to send the same response data\n to your app's server.\n\n | **Caution:** To preserve a good user experience in cases where a user interacts with your app on a variety of devices, be careful if you add rate-limiting based on number of devices.\n- Before verifying the contents of Google Play's response data on your private\n server, make an initial, authentication-based request to your private server. In\n this first request, send user credentials to your server, and have your server\n then respond with a *nonce* , or a number that is used only once. You can then\n include this nonce in your next request to your private server, asking for\n license verification data. For details on how to choose a good value for the\n nonce, see the [generate a suitable nonce value](#generate-nonce) section.\n\n | **Note:** Include a user ID field in both the nonce request and the license verification request. Your app's server can then compare the fields' values from the two requests and make sure they match.\n\n### Generate a suitable nonce value\n\nUse one of the following techniques to create a nonce value that's difficult to\nguess:\n\n- Generate a hash value based on the user's ID.\n- Generate a random value on a per-user basis. Store this random value on your app's server as part of a given user's attributes.\n\nVerify response data from your server\n-------------------------------------\n\nWhen reviewing response data that your app's server sends to your app, make sure\nthat the License Verification Library response isn't forged. Verify the\nsignature that's included in the app server's response data by comparing it\nwith the key that your app received from Google Play in a previous step.\n\nIt's also worth remembering that the block specific to the License Verification\nLibrary (LVL) is the only part that's signed. Therefore, it's the only part of\nyour app server's response data that your app should trust."]]