I noticed that you guys aded automatic token generation with Google. Currently, I have to do gcloud auth print-access-token to get the token, but I wanted to use the automatic token generation that has been included in the documentation.
My original code:
vertex_key ="some key"
headers = {
"X-Palm-Api-Key": vertex_key,
}
client = weaviate.connect_to_weaviate_cloud(
cluster_url=weaviate_url, # `weaviate_url`: your Weaviate URL
auth_credentials=Auth.api_key(weaviate_key), # `weaviate_key`: your Weaviate API key
headers=headers
)
My new code:
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = json_file_path
os.environ['USE_GOOGLE_AUTH'] = 'true'
client = weaviate.connect_to_weaviate_cloud(
cluster_url=weaviate_url, # `weaviate_url`: your Weaviate URL
auth_credentials=Auth.api_key(weaviate_key), # `weaviate_key`: your Weaviate API key
)
I just assumed we could remove the headers since it should automatically be generating a key. However, I get
ErrorObject(message="WeaviateInsertManyAllFailedError('Every object failed during insertion. Here is the set of all errors: Google API Key: no api key found neither in request header: X-Palm-Api-Key or X-Google-Api-Key or X-Google-Vertex-Api-Key or X-Google-Studio-Api-Key nor in environment variable under PALM_APIKEY or GOOGLE_APIKEY')
How do I implement automatic token generation properly?
I was trying to follow the documentation from that link and made changes as I showed in my code earlier, but I could not get it to work. I am using 1.25.10
I’m pretty sure I have set up the necessary steps on the server side and have the credentials json file set up. I assumed that I no longer need to pass the headers when connecting to the weaviate cloud since the json file should set it up for me which is why my new code is:
client = weaviate.connect_to_weaviate_cloud(
cluster_url=weaviate_url, # `weaviate_url`: your Weaviate URL
auth_credentials=Auth.api_key(weaviate_key), # `weaviate_key`: your Weaviate API key
# headers=headers
)
However, the error I get seems to indicate that I still need to either pass in the header or add an extra environment variable:
no api key found neither in request header: X-Palm-Api-Key or X-Google-Api-Key or X-Google-Vertex-Api-Key or X-Google-Studio-Api-Key nor in environment variable under PALM_APIKEY or GOOGLE_APIKEY'
My question is basically do I need to set the api key in the request header or in PALM_APIKEY or GOOGLE_APIKEY if I followed the steps in the documentation and already set USE_GOOGLE_AUTH to ‘true’ and have the json file?