google.auth.exceptions.DefaultCredentialsError: 文件未找到

huangapple go评论58阅读模式
英文:

google.auth.exceptions.DefaultCredentialsError: file was not found

问题

我已创建了Google Cloud Application Default Credentials,并将其存储在\ AppData \ Roaming \ gcloud中,供本地用户使用。

当我尝试在Python中实例化任何Google Cloud服务时,例如

storageclient = storage.Client(),

我收到一个错误

google.auth.exceptions.DefaultCredentialsError:找不到文件c:\ oldproject_id.json

它正在寻找一个我不再拥有的旧项目凭据JSON。如何重置它以使用Application Default Credentials JSON?

英文:

I have created Google Cloud Application Default Credentials and it is stored in \AppData\Roaming\gcloud for the local user.

When I try to instantiate any Google Cloud services in python, e.g.

storageclient = storage.Client(), 

I get an error

google.auth.exceptions.DefaultCredentialsError: file c:\oldproject_id.json not found 

It is looking for an old project credentials json I no longer have available. How do I reset it to make it use the Application Default Credentials json?

答案1

得分: 2

我通过移动JSON密钥文件并明确调用os.environ['GOOGLE_APPLICATION_CREDENTIALS']并指定我想要使用的JSON文件名来解决了这个问题。

英文:

I was able to address this by moving the json key file and explicitly calling os.environ['GOOGLE_APPLICATION_CREDENTIALS'] with the json file name I wanted to use.

huangapple
  • 本文由 发表于 2023年7月18日 03:11:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76707455.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定