如何使用.NET的Google Client API获取解码的Play Integnity API代币
我正在尝试使用 Google客户端API库的名称空间.net for .net for .net for decode filestity令牌,如播放完整性API文档。
但是,从图书馆文档中尚不清楚如何执行此操作。似乎应该从 deodeDrentegrityTokenResponse
对象返回解码的令牌有效负载,但是我找不到任何返回此类型的方法。
我希望这种类型将从 deodeStegtegrityToken(DecOdeTrentegrityTokenRequest,string)
中返回,但此方法实际上返回了另一种 deodeDoDeNtegrityTokenEctegrityTokenRequest
,这根本无济于事。
是否有人成功使用此库来解码令牌?
参考:
“
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...");
错误CS0029无法隐式转换类型'google.apis.playintegrity.v1.v1.v1.decodeintegritytokenrequest'到'google.apis.playintegrity.v1.data.decodeintegritytokenertegritytokenegritytokenertegritytokenertegritytokenertegritytokenertegritytokenegonsponse'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该依靠您的IDE来告诉您哪些类型这些对象是
您的代码说
deodeStegrityToken
应该返回deodeDodeNtegrityTokenResponse
。您是这样声明的,而不是使用var
,并允许编译器为您弄清楚。您的问题是,此方法实际上返回
DecoDeTrentegrityTokenRequest
。要获取
decodeTrityTokenResponse
您需要执行请求完整代码清理
You should rely on your ide to tell you what types these objects are
Your code says that the method
DecodeIntegrityToken
should return aDecodeIntegrityTokenResponse
. You are declaring it as such instead of usingvar
and allowing the compiler to figure it out for you.Your problem is that this method actually returns a
DecodeIntegrityTokenRequest
.To get a
DecodeIntegrityTokenResponse
you need to execute the requestFull code cleanup
我已经编写了一个示例应用程序,以使用自己的键在C#中验证和验证播放完整性。
官方文档没有C#代码示例。
示例应用程序包含.NET框架和Dotnet Core的代码。
克隆应用程序后,搜索// todo并使用适当的值进行更新。
csharp.playintegrity.decoder
I have written a sample application to decrypt and verify the play integrity in C# using their own keys offline.
The official documentation doesn't have a C# code sample.
The sample application contains code for both .net framework and dotnet core.
Once you clone the applciation, search for //TODO and update with appropriate values.
CSharp.PlayIntegrity.Decoder
您可以通过以下方式在本地解码证明语句。
我正在使用 jose.jwt 在这里使代码更加简单。
You can decode the attestation statement locally in the following way.
I am using Jose.jwt to make the code simpler here.