当我尝试调用 https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/subscriptions/{subscriptionId}/tokens/{token} 时从我的后端服务器验证我收到的购买:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"errors": [
{
"message": "Login Required.",
"domain": "global",
"reason": "required",
"location": "Authorization",
"locationType": "header"
}
],
"status": "UNAUTHENTICATED"
}
}
如何从我的后端服务器 进行身份验证(因此没有任何用户界面)?有什么办法可以在某处创建一个API key 并用它来进行身份验证吗?
最佳答案
错误信息
Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.
声明需要授权。
如果您查看 Method: purchases.subscriptions.get 的文档
您会注意到它声明此方法需要以下范围的授权
假设这是一个由您开发者控制的帐户,并且您只想访问这个单一帐户,您应该考虑使用服务帐户进行授权。文档在这里 Using a service account
关于android - 我在调用方法 : purchases. subscriptions.get 端点时收到未经验证的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64499652/