Tejas
Tejas

Reputation: 131

Vertex AI Managed Notebooks Authentication during Execution

I created a Managed Notebooks instance using the Compute Engine Service Account. I have some python code which reads from a BigQuery table and does some processing. I did 'gcloud auth application default login', logged into my google account, and then was able to access that BQ table (which otherwise gave access denied error).

Now, I want to run this notebook using the Executor. However, I get access denied errors since the Executor runs the notebook in a tenant project. This page mentions

Also, the executor cannot use end-user credentials to authenticate access to resources, for example, the gcloud auth login command.

To resolve these issues, in your notebook file's code, authenticate access to resources through a service account.

Then when you create an execution or schedule, specify the service account.

How do I authenticate access to resources through a service account? I tried setting the compute engine service account as the service account to be used in Executor settings, but it still gives me access denied error for that BQ table. What can I do within my code that is similar to running 'gcloud auth application default login'?

Upvotes: 0

Views: 1068

Answers (1)

morfys
morfys

Reputation: 2415

Can you try:

import google.auth
from google.cloud import storage
credentials, project = google.auth.default()

_GCS_STORAGE_CLIENT = storage.Client(google.auth.default()[1])

Upvotes: 0

Related Questions