我正在尝试使用从客户端(内部发行版)收到的令牌来验证用户购买。 为此,我将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控制台中为帐户授予管理员权限(出于测试目的),并在“ Google Cloud Console”控制台中将其设置为“项目所有者”(出于测试目的)再次)。
这里似乎有什么问题?