I try play the code given in exemple in this video : Introduction to Vertex AI SDK - https://www.youtube.com/watch?v=VaaUnIFCNX4
This the code used :
import pandas as pd
import seaborn as sns
import tensorflow as tf
import google
from google.cloud import bigquery
from google.cloud import aiplatform
from tensorflow import keras
from sklearn.preprocessing import LabelBinarizer
credentials, project_id = google.auth.default(
scopes=["https://www.googleapis.com/auth/cloud-platform"]
)
bqclient = bigquery.Client(credentials=credentials, project=project_id)
query_string = """
SELECT *
FROM `machine-learning-404417.Data_Beam.DryBeam`
"""
dataframe = bqclient.query(query_string).result().to_dataframe()
and I get this error :
Unauthorized: 401 POST https://bigquery.googleapis.com/bigquery/v2/projects/machine-learning-404417/jobs?prettyPrint=false:
Request had invalid authentication credentials.
Expected OAuth 2 access token, login cookie or other valid authentication credential.
See https://developers.google.com/identity/sign-in/web/devconsole-project.
My service account looks good :
Regards
Hello Luciano, thanks for your help I'm running this code on Colab Enterprise :
When I try : gcloud config list
i have :
as result
I add also the BigQuery User role to my account : as you can see.
but error message is the same :
Unauthorized: 401 POST https://bigquery.googleapis.com/bigquery/v2/projects/machine-learning-404417/jobs?prettyPrint=false:
Request had invalid authentication credentials.
Expected OAuth 2 access token, login cookie or other valid authentication credential.
See https://developers.google.com/identity/sign-in/web/devconsole-project.
Regards
where are you running this code? have you double check if the
gcloud cli
config is pointing to the service account as account? take a look on the output ofgcloud config list
. If not, and if you want to use this service acount, you need to set it in the SDK bygcloud config set account <service account id>
-- if you have your personnal account configured on thegcloud cli
, you can also addBigQuery User
role to it then you code may work fine as well.Also just as a sanity check, is the service account you showed created (or with access) on the
machine-learning-404417
, right?