【问题标题】:api key with google document ai带有谷歌文档 ai 的 api 密钥
【发布时间】:2020-12-28 12:44:10
【问题描述】:

我正在使用 google document ai 的表单解析器。 我发现的唯一身份验证方法是通过 gcloud 命令界面(“Authorization: Bearer”$(gcloud auth application-default print-access-token))。

我们的应用程序也使用 Google Vision,只需要一个 api 密钥 (https://vision.googleapis.com/v1/images:annotate?key=)

如何使用这种方式google document 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 google-api google-oauth


    【解决方案1】:

    请求缺少所需的身份验证凭据。

    表示您没有随请求发送任何授权

    您尝试的请求要求您发送访问令牌作为不记名令牌

    curl -H "Authorization: bearer <ACCESS_TOKEN>" http://www.example.com
    

    您似乎只发送了一个 API 密钥,该密钥只​​会授予您访问公共数据而非私人用户数据的权限。

    【讨论】:

    • 有远见,应用程序似乎只发送一个 api 密钥(标头只有一个内容类型),对我来说问题是我不想使用 gcloud 来获取访问令牌...
    • 您收到的错误消息表明它需要授权。这意味着您需要一个访问令牌。
    猜你喜欢
    • 1970-01-01
    • 2016-08-25
    • 2016-01-04
    • 1970-01-01
    • 1970-01-01
    • 2013-01-06
    • 1970-01-01
    相关资源
    最近更新 更多