简体   繁体   中英

Authentication with Google Document AI (Form Parser API)

I have been trying to authenticate from the parser API without success. I have set up the google service account and created two keys.I Have set up the owner role and downloaded the credential json file.

googleAuthR::gar_auth_service("D:/898 sample/document ai/form-898-scan-bd4b8b48b570.json")
library(daiR)

response1 <- dai_sync("D:/test file.pdf"
                      ,
                      proj_id = get_project_id(path = "D:/crudentialabc123.json"),
                      proc_id = "e4xxxxxx",
                      loc = "us",
                      token = dai_token(
                        path = Sys.getenv("GSC_AUTH_FILE")
                        # scopes = "https://googleapis.com/auth/cloud-platform"
                        )
                      )

I keep getting the 403 permission denied error.

File submitted at 2022-04-10 05:17:57. HTTP status: 403 - unsuccessful.
Error: "Permission 'documentai.processors.processOnline' denied on resource '//documentai.googleapis.com/projects/projectname/locations/us/processors/e4xxxxxxx' (or it may not exist)."
Response [https://us-documentai.googleapis.com/v1/projects/projectname/locations/us/processors/e46888f802fea83d:process]
  Date: 2022-04-10 05:17
  Status: 403
  Content-Type: application/json; charset=UTF-8
  Size: 649 B
{
  "error": {
    "code": 403,
    "message": "Permission 'documentai.processors.processOnline' denied on resource '//documentai.googleapis.com/projects/form-898-scan/locations/us/processors/e46...
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "IAM_PERMISSION_DENIED",
        "domain": "documentai.googleapis.com",
...

Any help would be appreciated!

I would recommend reviewing this blog post about Google authentication using R.

https://cran.r-project.org/web/packages/googleAuthR/vi.nettes/google-authentication-types.html

Currently, Google Cloud doesn't have any client libraries for R, but the 3rd party packages listed should be able to provide a starting point.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM