0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

gcloud_cliで、認証済みのアカウントにログインしてるのに、認証されない時

Posted at

firebase emulators を動かそうとした時に詰まった話です。

firebase emulators で、Firebase のプロジェクトの Firestore にデータを挿入しようとしたのにdefault credentialがないみたいなエラーが出ました。

2021/08/05 11:38:04 google: could not find default credentials. 
See https://developers.google.com/accounts/docs/application-default-credentials 
for more information.

以下の二つは既にやっていました。

  • ローカルのgcloud_clifirebase_cliで、gcloud auth loginfirebase loginとか使って、コンソール上で認証されているアカウントに、ログイン済み。
  • admin sdk キーの json もちゃんと指定してある。

試したこと

  • gcloud auth activate-service-account --key-fileでadmin sdkファイルを指定してみる。

解決策

調べたところ、以下のコマンドで「デフォルトアカウント」を設定する必要があったらしいです。

gcloud auth application-default login

Google: could not find default credentials · Issue #5 · circleci/docker-hello-google

解説

ユーザーのプロジェクトへの権限とかの credential の情報は、Application Default Credentials (ADC) で取得する必要があって、それを取得するには、gcloud auth loginではなく、gcloud auth application-default loginらしいです。

gcloud auth application-default | Cloud SDK Documentation

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?