0

I want to implement Google Document AI to read invoice details in salesforce using Rest API. I found below Api detail which is working well.

Now to call this api I need Oauth token. I have tired to setup Named Credentials but getting error "No_Oauth_Token: Access token was not returned". Can you please guide me for this? Might be I am setting wrong Scope, so can you please let me know which scope I need to setup.

Currently scope:- https://www.googleapis.com/auth/cloud-platform

enter image description here

curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    "https://LOCATION-documentai.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/processors/PROCESSOR_ID:process"

Also, if any other way is available, please suggest.

Looking forward to hear on this.

Thank you!

Looking for solution to get Google Authentication(Oauth) token which I can use to call Google Document AI api.

2 Answers2

0

Here is the information about setting up OAuth 2.0 for Google Cloud

https://support.google.com/cloud/answer/6158849?hl=en

And General Information about using OAuth 2.0 with Google APIs

https://developers.google.com/identity/protocols/oauth2

In addition, the REST request provided is not complete. It looks like you got the sample from this page https://cloud.google.com/document-ai/docs/send-request

On this page, you can click on the purple variables to replace them with the appropriate values for your setup (PROJECT_ID, LOCATION, etc)

Send Processing Request

Holt Skinner
  • 1,692
  • 1
  • 8
  • 21
  • I am clear with Document ai. Regarding OAuth token, It will be fully back-end side. No user interaction is there. So, I need rest api from where I can get OAuth token. can you please help me in that part. Also, Auth api I found that they need Scope, so I want to confirm about scope as well? – Dadhich Rami Nov 11 '22 at 12:19
0

I have done research base on above answer and found solution. Solution is to use JWT token. You can generate JWT token at your end and using that we can call google API to get valid Authentication token and then we can use respective Google APIs.