You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取Google Play Integrity API的完整性裁决响应?

解决Google Play Integrity API认证范围不足问题

核心说明

Google Play Integrity API的服务器端调用不需要OAuth 2.0用户授权范围,而是使用**服务账号(Service Account)**通过JSON Web Token(JWT)进行认证,这是你之前方向错误的关键。

Postman实现步骤

1. 创建并下载服务账号密钥

  • 打开Google Cloud Console,找到与Play Console关联的项目
  • 进入「IAM与管理」→「服务账号」
  • 点击「创建服务账号」,完成名称填写后创建账号
  • 在服务账号列表中找到刚创建的账号,点击「密钥」→「添加密钥」→「创建新密钥」
  • 选择JSON格式,下载密钥文件到本地

2. 配置Postman认证

  • 新建POST请求,URL填写https://playintegrity.googleapis.com/v1/{packageName}:decodeIntegrityToken,将{packageName}替换为你的应用包名
  • 切换到「Authorization」标签,类型选「OAuth 2.0」,点击「Get New Access Token」
  • 在弹窗中配置:
    • Grant Type选择「JWT Bearer」
    • JWT Audience填https://oauth2.googleapis.com/token
    • JWT Issuer填服务账号JSON文件中的client_email字段值
    • JWT Subject同样填client_email字段值
    • JWT Private Key直接复制JSON文件中的private_key内容(需保留首尾的密钥标识行和换行)
    • Scope填https://www.googleapis.com/auth/playintegrity(这就是你要找的权限范围)
  • 点击「Request Token」获取令牌后,选择「Use Token」

3. 构造请求体

  • 切换到「Body」标签,选「raw」→「JSON」,输入以下内容:
{
  "integrity_token": "你的Android端获取到的Integrity Token"
}

4. 发送请求

点击「Send」即可获取解密验证后的Integrity Verdict Response。

替代方案(gcloud命令行)

如果Postman配置繁琐,可使用gcloud CLI快速调用:

  1. 安装gcloud并完成登录:gcloud auth login
  2. 激活服务账号:gcloud auth activate-service-account --key-file=你的服务账号JSON文件路径
  3. 执行API调用:
curl -X POST "https://playintegrity.googleapis.com/v1/你的应用包名:decodeIntegrityToken" \
  -H "Authorization: Bearer $(gcloud auth print-access-token)" \
  -H "Content-Type: application/json" \
  -d '{"integrity_token": "你的Integrity Token"}'

内容的提问来源于stack exchange,提问作者Varnica Gupta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.03 07:30:55