I am trying to use the Google.Apis.PlayIntegrity.v1 namespace of the Google Client API library for .NET to decode an integrity token, as recommended in the Play Integrity API documentation.
However, it is unclear from the library documentation how to do this. It seems that the decoded token payload is supposed to be returned from a DecodeIntegrityTokenResponse
object, yet I can't find any method that returns this type.
I would expect that this type would be returned from DecodeIntegrityToken(DecodeIntegrityTokenRequest, String)
but this method actually returns another DecodeIntegrityTokenRequest
, which doesn't help at all.
Is anyone successfully using this library to decode the token?
References:
Attempted Code:
String integrityToken = "...token...";
String serviceAccountEmail = "...service account email...";
var certificate = new X509Certificate2("...key.p12...", "...secret...");
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { PlayIntegrityService.Scope.Playintegrity }
}.FromCertificate(certificate));
// Create the service.
var service = new PlayIntegrityService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "Play Integrity API Sample",
});
DecodeIntegrityTokenRequest request = new DecodeIntegrityTokenRequest();
request.IntegrityToken = integrityToken;
DecodeIntegrityTokenResponse response = service.V1.DecodeIntegrityToken(request, "...package name...");
Error CS0029 Cannot implicitly convert type 'Google.Apis.PlayIntegrity.v1.V1Resource.DecodeIntegrityTokenRequest' to 'Google.Apis.PlayIntegrity.v1.Data.DecodeIntegrityTokenResponse'