本文介绍了如何使用Google AI平台在线预测?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建了一个自定义的Tensorflow模型并将其部署到Google Cloud AI平台但是,当我向在线预测api发送发布请求时( https://ml.googleapis.com/v1/projects/my-project/models/my-model/versions/my-version:predict ).我回来了 401请求缺少必需的身份验证凭据.期望使用OAuth 2访问令牌.我了解通过部署模型,其API已经可以在线使用了,因此可以公开公开API吗?如果没有,我如何通过承载令牌进行api身份验证?解决方案
您可以使用gcloud获取身份验证令牌:
access_token = $(gcloud身份验证应用程序-默认打印访问令牌)
,然后将其嵌入到标题中:
curl --silent \-H授权:承载$ access_token" \-H内容类型:application/json" \-X POST \
等
i created a custom tensorflow model and deployed to google cloud AI platformhowever, when i sent a post request to online prediction api (https://ml.googleapis.com/v1/projects/my-project/models/my-model/versions/my-version:predict). i got back 401 Request is missing required authentication credential. Expected OAuth 2 access token my understand that by deploying model is its API already available online, so is there away to make API public? if not how i can make api authentication through bearer token?
解决方案
You can get the auth token using gcloud:
access_token=$(gcloud auth application-default print-access-token)
and then embed it into the header:
curl --silent \
-H "Authorization: Bearer $access_token" \
-H "Content-Type: application/json" \
-X POST \
etc.
这篇关于如何使用Google AI平台在线预测?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!