I was trying this pub/sub client tutorial, and got this error in publisher.py
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
when I call this part.
publisher = pubsub_v1.PublisherClient()
I am a member of a GCP group which has already pubsub.publisher, pubsub.subscriber roles. And I registered my account on my local machine. So, if I use CLI command on terminal like
gcloud pubsub topics publish <topic-name> --message="help me"
It succeeds.
I can see that python script can be seen as a service, so it needs service account. But is there any way to use my group's credentials in python script too, or should I use a service account?
(12.03.2021 updated 1) Thanks for answering guys, (Sorry, I'm noob in GCP). I have no roles to give specific roles to a service account, which means that I cannot make a service account that has roles pubsub.publisher and pubsub.subscriber. (this is our department's policy. is it kind of wired??) So for the tutorials in local machine, I just want to use groups IAM (user account IAM) for a credentials. Is there no way not to use service account?? (I just thought that there is a way even though python script can be seen as a service)
(12.03.2021 updated 2)
gcloud auth application-default login
worked as suggested by here