api key with google document ai

Viewed 374

I am using the form parser of google document ai. The only way to authenticate that I have found is through gcloud command interface ("Authorization: Bearer "$(gcloud auth application-default print-access-token)).

Our application uses Google Vision too and just needs an api key (https://vision.googleapis.com/v1/images:annotate?key=)

How can I use this way google document AI?

I have tried with the api key in /apis/credentials and I have tried to restrict the key to ip too and to document ai api, but all with the same result:

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

What am I missing?

2 Answers

Request is missing required authentication credential.

Means that you have not sent any authorization with your request

The request you are attempting requires that you send an access token along as a bearer token

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

You appear to only be sending an API key which will only grant you access to public data not private user data.

Related