python - 验证 Google Store 应用内购买需要哪些权限?

标签 python google-cloud-platform google-play in-app-purchase subscription

我正在尝试使用从客户端收到的 token (内部版本)验证用户购买。 为此,我将 Python 脚本与 Google Python API 客户端 ( https://github.com/googleapis/google-api-python-client ) 结合使用。

    import httplib2
    from oauth2client.service_account import ServiceAccountCredentials

    token = "token received from the client"

    http = httplib2.Http(timeout=self.http_timeout)

    credentials = ServiceAccountCredentials.from_json_keyfile_name(
        "./service_account.json", "https://www.googleapis.com/auth/androidpublisher"
    )
    http = credentials.authorize(http)

    result = build("androidpublisher", "v3", http=http)\
            .purchases()\
            .products()\
            .get(packageName="<package name>", productId="<subscription id>", token=token)\
            .execute(http=http)

我从这个电话中得到的回应是:

HttpError 401 when requesting https://www.googleapis.com/androidpublisher/v3/applications/<package name>/purchases/products/<subscription id>/tokens/<token>?alt=json returned "The current user has insufficient permissions to perform the requested operation."

正在使用的服务用户在 Google Play Console 中授予帐户管理员权限(为了测试),并在“Google Cloud Console”控制台中设置为“Project Owner”(为了测试)再次)。

这里似乎出了什么问题?

最佳答案

“所有者”权限足以进行收据验证 [Source] .

您遇到的错误很可能是传播问题,服务凭证实际上可能需要大约 24 小时才能在整个系统中生效。

关于python - 验证 Google Store 应用内购买需要哪些权限?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56952212/

相关文章:

Java 应用程序找不到访问 GCP Pub/Sub 的凭据

google-cloud-platform - 多个项目的 BigQuery 服务帐号配置

android - google play 上 android 应用程序的描述,语言不同于英语

android - 在 Play Store 上发布 Android app bundle 有没有上限?

javascript - Python 与 Javascript 浮点运算给出了截然不同的答案。我究竟做错了什么?

python - 如何在python mysql中防止CREATE查询中的注入(inject)攻击

google-cloud-platform - GCP : Instance creation failed

android - Cordova:android 和 ios 平台可以有不同的应用程序 ID 吗?

python - 偶数和奇数之和包括超出范围的数字(如果不是偶数或奇数)

python - 如何在 h5py 中使用 HDF5 尺寸刻度