我正在尝试使用GooglePlayIntegrityAPI验证完整性。
- 将Android应用程序生成的Nonce传递给IntegrityAPI,并从IntegrityAPI获取令牌(这是成功的(
- 将令牌从Android应用程序发送到应用程序服务器
- 应用服务器查询Play的服务器以解密&验证令牌
- Play的服务器返回令牌负载
我的问题是3-4。(对不起,我弄错了(图像
GoogleServer向MyAppServer返回以下错误。
"Code": 400,
"Message": "App is not found.",
"ErrorResponseContent": "
{
"error": {
"code": 400,
"message": "App is not found.",
"errors": [
{
"message": "App is not found.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
"
原因是什么?顺便说一句,Android应用程序返回400 Bad请求(这是Appserver生成的错误,所以这并不重要(。
**更新(2022/10/21(**
这是我的代码,GoogleIntegrityAPI从AppServer调用(不是从我的AndroidApp(。
var credentialJson = "...credential json...";
var credential = GoogleCredential.FromJson(credentialJson)
.CreateScoped(new[] { PlayIntegrityService.Scope.Playintegrity }).UnderlyingCredential;
var playIntegrityService = new PlayIntegrityService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "...application name..."
});
var requestBody = new DecodeIntegrityTokenRequest
{
IntegrityToken = "...token..."
};
var request = playIntegrityService.V1.DecodeIntegrityToken(requestBody, "...package name...");
var response = await request.ExecuteAsync();
谢谢。
我搞定了!我错误地将我的Android应用程序的ApplicationID作为ApplicationName传递给了服务器端。ApplicationID和ApplicationName原则上是相同的值,但我在ApplicationID后面加了一个Develop后缀。这就是为什么找不到应用程序的原因。
productFlavors {
create("aaa") {
dimension = "default"
}
create("bbb") {
dimension = "default"
applicationIdSuffix = ".bbb"
}
}
我通过了com.sample.myapp.bbb
,但我应该只使用com.sample.myapp
。
谢谢。