76
43

More than 3 years have passed since last update.

firebaseのチュートリアルで、Error: Missing or insufficient permissions.と言われた時の解決法メモ

Last updated at Posted at 2018-02-11

firebaseのチュートリアルを行おうとしていたら、以下の部分でチュートリアル通りの画面がでなかった。
codelabs

開発ツールを開くと、以下のエラーが出ていた。

Error: Missing or insufficient permissions.

権限管理の何か、、というので、firebaseコンソール権限周りを見ていたら、データベースの設定で怪しげなところが。

2018-02-11.png

cloneしたファイルの中に、データベースの設定があったのを思い出す。

firestore.rules
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

これをコピーして、公開したらエラーは消えた。

2018-02-11 (1).png

※追記

次の項目に、データベースルールの変更法について記述ありましたね。

5. Write Data to Firestore

チュートリアルソース※開始時点

チュートリアルソース※終了時点

追記

データを安全にクエリする も一読したほうがよさそう。

あるアプリに、ユーザーが作成した story ドキュメントのリストを表示するページを含めるとします。次のクエリを使用してこのページのデータを取得できそうに思えますが、セキュリティ ルールと同じ制約が含まれていないため、このクエリは失敗します。
無効: クエリの制約がセキュリティ ルールの制約と一致していない

// This query will fail
db.collection("stories").get()
76
43
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
76
43