2

I am a novice developer who wants to learn how to use artificial intelligence. So I created model and it responds correctly according to the inputs. So I want to test using postman a call to the API to verify that everything works and I have an error in my call: "message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "status": "UNAUTHENTICATED" I don't know how to authenticate myself to retrieve the access token. Could you help me find a solution please?

4

1 回答 1

1

您有 2 个解决方案:

  • 正如约翰所说,
    • 在您的计算机上安装 gcloud SDK。
    • 使用命令gcloud auth logingcloud init(在安装结束时建议)验证自己
    • 生成访问令牌gcloud auth print-access-token并复制它
      • 提示:如果您使用 Cloud Shell,则可以跳过前 2 个步骤
    • 将访问令牌添加到您的 Postman 请求的标头中,如下所示:
      • 关键是“授权”
      • 价值是“承载者”
    • 访问令牌有效 1H,然后您必须生成一个新的。
  • (不推荐)像这样公开您的模型(即未经身份验证)(仅在命令行中,它在 GUI 上不起作用)
gcloud ai-platform models add-iam-policy-binding --member="allUsers" \
  --role="roles/ml.modelOwner" <Model Name>

用您部署的模型替换模型名称。但是,它仅用于测试目的。您有任何过滤器,任何人都可以使用它,您将支付处理费用。

于 2020-11-19T10:41:16.103 回答