Streamlit app authenticate with Google Cloud Document AI

Hi Shraavani thank you so much for your reply :raised_hands:. I have been able to get my deployed app working because of your suggestions :heart::rocket::heart_eyes:.

The major difference was I had the incorrect IAM permission set on my service account - I set it as “Document AI Admin” - however, your clear concise explanation and examples were also a major help.

I wasn’t sure how to connect to the credentials once I entered them in the st App settings/Secrets, so I used the following code:

import streamlit as st
from google.cloud import documentai
from google.oauth2 import service_account

credentials = service_account.Credentials.from_service_account_info(
    st.secrets["gcs_connections"]

client = documentai.DocumentProcessorServiceClient(credentials=credentials)

where “gcs_connections” is the TOML section for the GCS auth crednetials in Secrets https://docs.streamlit.io/streamlit-community-cloud/get-started/deploy-an-app/connect-to-data-sources/secrets-management

Thank you so much once again :hugs:

Cheers

2 Likes