0

I am trying to parse documents through Document AI batchprocess and while sending get request to document AI to get the response I get the error Caller does not have permission.Any solution there for this.Here I am attaching the picture for reference.enter image description here

1 Answers1

0

Quoted from this doc:

Google Cloud APIs use the OAuth 2.0 protocol for authenticating both user accounts and service accounts. The OAuth 2.0 authentication process determines both the principal and the application.

Most Google Cloud APIs also support anonymous access to public data using API keys. However, API keys only identify the application, not the principal. When using API keys, the principal must be authenticated by other means.

I can see that you are using an API key to try and authorize the call from the URL. If you are using the API key, it only identifies the application, not the principal. So you should have to authenticate the principal(User or Service Account) using OAuth 2.0. Refer to this doc for more information.

  • Try setting the following in the headers as mentioned in the "Try this API -> credentials -> click on (?)":
GET https://documentai.googleapis.com/v1/%5BNAME%5D?key=[YOUR_API_KEY] HTTP/1.1

Authorization: Bearer [YOUR_ACCESS_TOKEN]

Accept: application/json
  • Where YOUR_ACCESS_TOKEN can be found using the Cloud SDK and using the following command:

gcloud auth application-default print-access-token - This command is used for to print an access token for your current Application Default Credentials.

Vishal K
  • 1,368
  • 1
  • 7
  • 15