使用服务帐户进行身份验证。 Google Vision提供的PDF / TIFF文档文本检测服务

时间:2019-01-22 19:34:30

标签: google-cloud-platform google-vision

我正在尝试使用Google Vision OCR功能,以便从某些扫描的旧版PDF中提取文本。该API已添加到我的项目中,创建了帐户服务,并已授予对关联存储间隔的访问权限。当我尝试运行命令执行操作时,收到以下错误消息:

curl: (3) [globbing] bad range specification in column 11
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched brace in column 1
curl: (6) Could not resolve host: gcsSource
curl: (3) [globbing] unmatched brace in column 1
curl: (3) [globbing] unmatched close brace/bracket in column 47
curl: (3) [globbing] bad range specification in column 2
curl: (3) [globbing] nested brace in column 17
curl: (3) [globbing] unmatched close brace/bracket in column 28
curl: (3) [globbing] unmatched close brace/bracket in column 2

{
  "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"
  }
}

身份验证有什么问题?我已经尝试使用默认应用程序的打印访问令牌代替服务帐户生成的打印访问令牌

我已经读过: -https://cloud.google.com/vision/docs/pdf#vision-web-detection-gcs-protocol -I want to use PDF/TIFF Document Text Detection service from google cloud

curl -H "Authorization: Bearer "$(MY-PRINT-ACCESS-TOKEN) --header "Content-Type: application/json"   --request POST   --data '{ "requests":[  {"inputConfig": { "gcsSource": {  "uri": "gs://sentinelasdafronteira/relatorios/1830.pdf"},"mimeType":"application/pdf"},"features": [{"type":"DOCUMENT_TEXT_DETECTION"}],"outputConfig": {"gcsDestination":{"uri": "gs://sentinelasdafronteira/"},"batchSize": 2}}]}' https://vision.googleapis.com/v1/files:asyncBatchAnnotate

0 个答案:

没有答案