Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable warning when using end user credentials in GCP scripts

I am running some scripts to do some ad-hoc jobs in GCP, using the Python client libraries.
These are ad-hoc and thus I believe they should be run on my end user credentials instead of a service account.

I keep seeing this warning and it makes it hard to debug my script standard output:

UserWarning: Your application has authenticated using end user credentials from Google Cloud SDK without a quota project. You might receive a "quota exceeded" or "API not enabled" error. We recommend you rerun `gcloud auth application-default login` and make sure a quota project is added. Or you can use service accounts instead. For more information about service accounts, see https://cloud.google.com/docs/authentication/

I did the suggested gcloud auth application-default login but the same warning message still appears repeatedly.

How do I disable this warning?

like image 319
cryanbhu Avatar asked May 10 '26 00:05

cryanbhu


2 Answers

Have a look at the lines in the library. The message is hardcoded into the function named _warn_about_problematic_credentials (starting on line 59).

If you go deeper into the file, you can see that the warning message is displayed only if there isn't a quota project defined.

You may use the following command to add a quota project to your application-default credentials:

gcloud auth application-default set-quota-project <YOUR PROJECT ID>
like image 160
guillaume blaquiere Avatar answered May 11 '26 15:05

guillaume blaquiere


I managed to disable this simply by using a Python ignore warning option as I read here.

python3 -W ignore my_script.py

If you want to be more precise and only disable certain warnings you can try this.

like image 34
cryanbhu Avatar answered May 11 '26 13:05

cryanbhu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!