【发布时间】:2022-09-27 18:19:45
【问题描述】:
我正在尝试向我的 google vertex ai 端点发送一个 http post 请求以进行预测。尽管我确实在请求标头中设置了承载令牌,但请求仍然失败并出现以下错误:
{
\"error\": {
\"code\": 401,
\"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\",
\"details\": [
{
\"@type\": \"type.googleapis.com/google.rpc.ErrorInfo\",
\"reason\": \"ACCESS_TOKEN_TYPE_UNSUPPORTED\",
\"metadata\": {
\"service\": \"aiplatform.googleapis.com\",
\"method\": \"google.cloud.aiplatform.v1.PredictionService.Predict\"
}
}
]
}
}
由于我是从 python 后端进行此调用的,因此我不确定消息中建议的 OAuth 2 是否是明智且适用的选择。
该模型已经部署并在顶点 ai 上进行了端点测试,并且运行良好。我想做的是使用邮递员通过http post请求发送相同的预测任务,这就是失败的原因。
请求网址如下所示:
https://[LOCATION]-aiplatform.googleapis.com/v1/projects/[PROJECT ID]/locations/[LOCATION]/endpoints/[ENDPOINT ID]:predict
其中令牌持有者在 potman 授权选项卡中设置,实例在请求正文中设置。
-
你能分享你的代码让我们重现你的场景吗
-
@AnjelaB该模型已经部署并在顶点ai上进行了终点测试,并且运行良好。我想做的是使用邮递员通过http post请求发送相同的预测任务,这就是失败的原因。
-
@AnjelaB 我已经更详细地更新了这个问题。
标签: python google-cloud-platform google-cloud-endpoints google-cloud-ml google-cloud-vertex-ai