android - 我在调用方法 : purchases. subscriptions.get 端点时收到未经验证的错误

标签 android google-api google-play in-app-purchase google-play-services

当我尝试调用 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 的文档

您会注意到它声明此方法需要以下范围的授权

enter image description here

假设这是一个由您开发者控制的帐户,并且您只想访问这个单一帐户,您应该考虑使用服务帐户进行授权。文档在这里 Using a service account

关于android - 我在调用方法 : purchases. subscriptions.get 端点时收到未经验证的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64499652/

相关文章:

java - 设备支持删除了在 Playstore Android 上更新应用程序时出现的警告

java - 由于 AccessibilityNodeInfo getChild 而导致大量 ANR

android - 从 DialogFragment 中的 EditText 中检索值

c# - 来自 C# 的 Google Drive API 错误请求,但来自 Postman 的请求很好

javascript - 谷歌API选择器: google is not defined

android - 如何使用google contacts api以编程方式将手机联系人同步到android中的gmail

android - 获取android google play评论的API(获取设备名称和应用版本)

android - 如何将音频流传输到Android设备?

android - FQL 使用 facebook android SDK

Android Studio App Inspector 不显示数据库