Search code examples
c#.netgoogle-playgoogle-play-servicesgoogle-play-integrity-api

How to verify Play Integrity API token using the Google Client API for .NET


I'm trying to verify whether my token generated in Play Integrity is valid. For now I could decrypt my token. However, I didn't find API if it exists to verify that token. Could you please point me if it possible. Thank you in advance.

var credential = GoogleCredential.FromFile(jsonFile);

var service = new PlayIntegrityService(
    new BaseClientService.Initializer
    {
        HttpClientInitializer = credential,
        ApplicationName = "MyApp",
    });

var requestBody = new DecodeIntegrityTokenRequest
{
    IntegrityToken = integrityToken
};


var request = service.V1.DecodeIntegrityToken(requestBody, packageName);

var result = request.Execute();

Packages:

"Google.Apis" Version="1.60.0"
"Google.Apis.Auth" Version="1.60.0"
"Google.Apis.PlayIntegrity.v1" Version="1.60.0.2926"

Solution

  • As I see PlayIntegrityService making only verdicts such as: appLicensingVerdict, deviceRecognitionVerdict, appRecognitionVerdict. It doesn't make any verifications, so you should do it on your own in code. For more information about verdicts see: Work with integrity verdicts