0

I have been tasked with trying to use the Google DocumentAI service to extract table data from PDF files. I am using Alteryx, but the principle would apply to PostMan or other apps where you format your own requests.

I have set up a Google Cloud Bucket, and loaded up my PDFs. I have set up a project, and got a Service Account.

The documentation shows formatting a request, and has the Authorization header as "Authorization: Bearer gcloud auth application-default print-access-token".

Given that I have the credentials json file like this...

{
  "type": "service_account",
  "project_id": "my-proj",
  "private_key_id": "12345abc",
  "private_key": "-----BEGIN PRIVATE KEY-----\stuff\n-----END PRIVATE KEY-----\n",
  "client_email": "me@my-proj.iam.gserviceaccount.com",
  "client_id": "12345",
  "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  "token_uri": "https://oauth2.googleapis.com/token",
  "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/me%40my-proj.iam.gserviceaccount.com"
}

... How do I get the bearer token? I assume I will have to make some kind of call to the identity server, but it is not clear how to do this.

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
Steve Hibbert
  • 2,045
  • 4
  • 30
  • 49
  • 1
    If you get service accounts working with postman i would love to see the code. But here is some documentation. https://developers.google.com/identity/protocols/oauth2/service-account I have tried several times over the last eight years. – Linda Lawton - DaImTo Dec 14 '20 at 14:25
  • 1
    Thanks @DaImTo, looks like I have to build my own JWT. It's possible in Alteryx, but the SHA-256 encryption has to be done with a plug-in. Appreciate the doc link. Will update if I make progress. – Steve Hibbert Dec 15 '20 at 15:50
  • Tip from my own attempts its time critical the payload times cant be more then a few minutes old. – Linda Lawton - DaImTo Dec 15 '20 at 21:11
  • 1
    Oddly, this has just bitten me with another API. I created a token with a timestamp and the request took so long it became stale half way through the file download. Great comment, thank you. – Steve Hibbert Dec 22 '20 at 08:48

0 Answers0