Closed mahimairaja closed 2 months ago
Have you configured gcloud and run gcloud auth application-default login
?
@mahimairaja Like Eno mentioned above this points at an auth issue probably from not setting ADC credentials properly which the Python Connector uses for authentication. You can read more about setting ADC credentials here.
Are you running your code on a GCE VM or local machine? It seems the auth library thinks you are running from a compute engine based on the error message.
Hi @enocom and @jackwotherspoon.
From my understanding. setting ADC will automatically involves the initialization of IAM right?
BTW, I am facing this issue while deploying the app using FastAPI
(Also, this works well in the GCE VM @jackwotherspoon )
From my understanding. setting ADC will automatically involves the initialization of IAM right?
Not sure I fully understand the sentence. For local deployment on your local machine (aka FastAPI development) you need to set ADC credentials following the steps for setting up ADC.
Either gcloud auth application-default login
for setting IAM user credentials or you can set env variable GOOGLE_APPLICATION_CREDENTIALS
to the path of a service account JSON file for an IAM service account.
In a deployed Google application environment (GCE, Cloud Run etc.) the ADC credentials are automatically set to the service account in the environment which is why you don't see this issue when deploying in other environments and only locally.
From my understanding. setting ADC will automatically involves the initialization of IAM right?
Setting ADC up will ensure that the Python Connector running on your local machine can retrieve an OAuth2 token when sending requests to the API.
BTW, I am facing this issue while deploying the app using FastAPI
On your local machine? Or elsewhere?
I recently resolved on my local machine using the ADC. But, then I would like to setup CI using the pytest on Github actions. How can I authenticate in side the github actions checkout?
@enocom and @jackwotherspoon any idea?
@mahimairaja Yes you can just use the google-github-actions/auth Github Action. We recommend using the Github Action with Workload Identity Federation for the best workflow.
Here is a great blog showcasing the two together.
This is matter of fact the exact setup we use for our own integration tests in this repo: https://github.com/GoogleCloudPlatform/alloydb-python-connector/blob/f2906196ef699ae056ba1ce1777b86cdbecf0a68/.github/workflows/tests.yaml#L155-L161
Hope this helps 😄 Going to close out this issue as the original question was answered and resolved.
Thanks you it resolves!!!
Hi, i am facing an authentication issue while connection using the pg800 python connectors;
✅ Enabled Public IP for the instance
Code:
Error Message:
Please let me know, how to connect from local machine using the Public IP method.