curl - 带有谷歌文档 ai 的 api 密钥
问题描述
我正在使用谷歌文档 ai 的表单解析器。我发现的唯一身份验证方法是通过 gcloud 命令界面(“Authorization: Bearer”$(gcloud auth application-default print-access-token))。
我们的应用程序也使用 Google Vision,只需要一个 api 密钥 ( https://vision.googleapis.com/v1/images:annotate?key= )
我怎样才能使用这种方式谷歌文档AI?
我已经尝试使用 /apis/credentials 中的 api 密钥,并且我也尝试将密钥限制为 ip 并记录 ai api,但结果都相同:
curl -v -X POST -H "Content-Type: application/json; charset=utf-8" -d @request.json https://eu-documentai.googleapis.com/v1beta3/projects/<project id>/locations/eu/processors/<processor id>:process?key=<api key>
{
"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.",
"status": "UNAUTHENTICATED"
}
}
我错过了什么?
解决方案
请求缺少所需的身份验证凭据。
表示您没有随请求发送任何授权
您尝试的请求要求您发送访问令牌作为不记名令牌
curl -H "Authorization: bearer <ACCESS_TOKEN>" http://www.example.com
您似乎只发送了一个 API 密钥,它只会授予您访问公共数据而非私人用户数据的权限。
推荐阅读
- node.js - 为什么 Windows 容器中的 Dockerized Node.js WebApp 无法启动
- android - 如何删除 WebView 上的 AppBar?
- python - Python Eve - 日期时间过滤在 Ubuntu 20.04 上不起作用
- autodesk-forge - 初始化 PackAndGoLib.PackAndGoComponent 时类未注册异常
- mysql - Ubuntu 服务器端口 3306 在启动时已经在监听
- python - 管道中 Scikit-learn(隔离森林)中的异常值检测
- swift - 如何在 swift 中创建类似于我的 kotlin 拦截器?
- php - 无法从 json 单元格获取 url 值
- php - Wordpress:慢速编辑帖子
- node.js - Ajax在香草js中获取请求