we are having more than one project in one google service account and each project is having separate GOOGLE_APPLICATION_CREDENTIALS
json file. As per requirement based on locale and projectID
we have to use relevant credential json file.
Tried loading through environment variable but that can accept only one file path,
Set environment variable
GOOGLE_APPLICATION_CREDENTIALS="/home/user/Downloads/[FILE_NAME].json"
expect authentication success if request is coming from any project with in that service account.
Creating a Credential FileOpen the Credential page. Select the project you are creating credentials for. At Credentials, Click Create credentials and select Service account as shown below. At the Service Accounts, enter a service account name and click Create.
You need to set credentials from json file directly instead of setting it in the environment variable.
from google.oauth2 import service_account
SERVICE_ACCOUNT_FILE = "/home/user/Downloads/[FILE_NAME].json"
credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE)
project_id = "project_id"
session_id = "session_id"
session_client = dialogflow.SessionsClient(credentials=credentials)
session = session_client.session_path(project_id, session_id)
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With