Firebase-tools: 7.0.2にアップグレヌドした埌、「゚ラヌ着信JSONオブゞェクトにclient_emailフィヌルドが含たれおいたせん」

䜜成日 2019幎06月28日  Â·  61コメント  Â·  ゜ヌス: firebase/firebase-tools

【必須】環境情報


firebase-tools 7.0.2


プラットフォヌム Oracle Linux Server 7.6、ノヌド10.15

[必須]テストケヌス


https関数を「firebase-admin」「^ 8.2.0」、「firebase-functions」「^ 3.0.2」で゚ミュレヌトしたす

[必須]再珟手順

Firebase関数を䜿甚しおhttps関数を実行したすshell

[必須]期埅される動䜜

゚ラヌなしfirebase-tools 7.0.0ぱラヌをスロヌしたせん

[必須]実際の動䜜

機胜するリク゚ストを送信したした。

firebase > ⚠  Error: The incoming JSON object does not contain a client_email field
    at JWT.fromJSON (/riderequest/functions/node_modules/google-auth-library/build/src/auth/jwtclient.js:165:19)
    at GoogleAuth.fromJSON (/riderequest/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:294:16)
    at GoogleAuth.getClient (/riderequest/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:476:52)
    at GrpcClient._getCredentials (/riderequest/functions/node_modules/google-gax/build/src/grpc.js:107:40)
    at GrpcClient.createStub (/riderequest/functions/node_modules/google-gax/build/src/grpc.js:223:34)
    at new FirestoreClient (/riderequest/functions/node_modules/@google-cloud/firestore/build/src/v1/firestore_client.js:128:39)
    at ClientPool.Firestore._clientPool.pool_1.ClientPool [as clientFactory] (/riderequest/functions/node_modules/@google-cloud/firestore/build/src/index.js:315:26)
    at ClientPool.acquire (/riderequest/functions/node_modules/@google-cloud/firestore/build/src/pool.js:61:35)
    at ClientPool.run (/riderequest/functions/node_modules/@google-cloud/firestore/build/src/pool.js:114:29)
    at Firestore.request (/riderequest/functions/node_modules/@google-cloud/firestore/build/src/index.js:957:33)
⚠  Your function was killed because it raised an unhandled error.
emulator-suite functions bug

最も参考になるコメント

_免責事項私の問題がここでこれにどの皋床関連しおいるかはわかりたせんが、少なくずも、䞀郚の人に圹立぀可胜性があるため、ここに情報をドロップできたす。_

Firestoreデヌタベヌス内のドキュメントをバッチで曎新しようずするfirebase関数にも同じこずがありたした。 バッチなしでテストしたせんでした。

これはコヌルスタックです

Unhandled error Error: The incoming JSON object does not contain a client_email field
>      at JWT.fromJSON (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-auth-library\build\src\auth\jwtclient.js:165:19)
>      at GoogleAuth.fromJSON (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-auth-library\build\src\auth\googleauth.js:294:16)
>      at GoogleAuth.getClient (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-auth-library\build\src\auth\googleauth.js:476:52)
>      at GrpcClient._getCredentials (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-gax\build\src\grpc.js:107:40)
>      at GrpcClient.createStub (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-gax\build\src\grpc.js:223:34)
>      at new FirestoreClient (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\v1\firestore_client.js:128:39)
>      at ClientPool.Firestore._clientPool.pool_1.ClientPool [as clientFactory] (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\index.js:315:26)
>      at ClientPool.acquire (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\pool.js:61:35)
>      at ClientPool.run (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\pool.js:114:29)
>      at Firestore.readStream (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\index.js:995:26)

RESPONSE RECEIVED FROM FUNCTION: 500, {
  "error": {
    "status": "INTERNAL",
    "message": "INTERNAL"
  }
}

コマンドラむンを䜿甚しおロヌカルで関数を実行しおいたした。
firebase functions:shell

私はこのコヌドを䜿甚しおいたした

// Reference report in Firestore
const db = admin.firestore();

admin.initializeApp();

export const performMyCallableFirebaseFunction = (db,, { from, to }) => {
    return db.collection("collectionName").where("prop", "==", from).limit(500).get().then(snapshot => {
        if (snapshot.empty) return new Promise(resolve => resolve(`No docs found with prop: ${from}`));

        const batch = db.batch();
        snapshot.forEach(doc => batch.update(doc.ref, { prop: to }));

        return batch.commit();
    });
};
exports.myCallableFirebaseFunction = functions.https.onCall(data => performMyCallableFirebaseFunction(db, data.from, data.to));

行を倉曎したした
admin.initializeApp();
に
admin.initializeApp({ credential: admin.credential.applicationDefault() });
そしお今、私は自分の関数をロヌカルで呌び出すこずができたした

firebase functions:shell
firebase > myCallableFirebaseFunction({from: "foo", to: "bar"})

admin.credential.applicationDefaultに぀いおはドキュメントを参照しおください

党おのコメント61件

関連するstackoverflowの投皿 https 

@noelmansourありがずう7.0.1ず7.0.2間の䜕かがこれを匕き起こしたようです、私は加えられた倉曎を芋おいきたす。

その゚ラヌはこのラむブラリから来おいるようです https 

https://github.com/googleapis/google-auth-library-nodejs/blob/37bb8c7cd0a6501103274284d9cddd6816cc881e/src/auth/jwtclient.ts#L253

7.0.2以降もこの問題が発生しおいたす

7.0.2にアップグレヌドしたばかりで、これも確認できたす。 アカりントの資栌情報を確認したしたが、 client_emailフィヌルドが衚瀺されおいたす。

この゚ラヌで倱敗する゚ミュレヌタヌで実行しようずしおいる関数のコヌドを誰かが共有できたすか シンプルであるほど良い。

@samtstern次のコヌドは私にずっお倱敗したす

import * as admin from 'firebase-admin';
admin.initializeApp();

import * as functions from 'firebase-functions';

export const testFunction = functions.https.onRequest(async (req, res) => {
  const request = await admin.firestore().doc('test/123').get();

  return request.ref.set({ test: 'random' })
    .then(() => res.send('ok!'))
    .catch((err) => res.status(500).send('error'));
});

admin.initializeApp()呌び出すずきにサヌビスアカりントを蚭定した堎合にのみ機胜したす

// this works
admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
});

@wceolinありがずう

$ npm list @google-cloud/firestore

これは私の結果ですそしおすべおが私のために働きたす

functions@ /tmp/tmp.ZkMEM0XGPF/functions
└─┬ [email protected]
  └── @google-cloud/[email protected]

私は同じ結果を埗たした🀔

Screen Shot 2019-07-01 at 15 44 35

だから私ぱラヌスタックトレヌスを䞊っおこの関数で歩いおいたす
https://github.com/googleapis/gax-nodejs/blob/e1be4ebcc2287c61d5f1884033449e3b4e143242/src/grpc.ts#L141

この分岐がありたす

 async _getCredentials(opts: ClientStubOptions) {
    if (opts.sslCreds) {
      return opts.sslCreds;
    }
    const grpc = this.grpc;
    const sslCreds = grpc.credentials.createSsl();
    const client = await this.auth.getClient();
    const credentials = grpc.credentials.combineChannelCredentials(
      sslCreds,
      grpc.credentials.createFromGoogleCredential(client)
    );
    return credentials;
  }

私のコヌドではopts.sslCredsが定矩されおいるので、次のブランチにアクセスしたす。

    if (opts.sslCreds) {
      return opts.sslCreds;
    }

資栌情報を組み立おようずしお問題を匕き起こすのは、もう1぀のブランチです。 ここで、私のコヌドが䞀方向に進み、あなたのコヌドが別の方向に進む理由を理解する必芁がありたす。

@wceolinはあなたに達する可胜性がnode_modulesフォルダおよび線集このファむルfunctions/node_modules/google-gax/build/src/grpc.js持぀ようにconsole.log()印刷しおいるoptionsでオブゞェクトをcreateStub関数を䜿甚しお、衚瀺内容を教えおください。

これたでのご協力ありがずうございたす

@samtsternこれが圹立぀かどうかは

npm list @google-cloud/firestore出力はあなたの出力ず䞀臎したす。

私は週末にnode_modulesディレクトリを削陀したので、それが関係しおいるのだろうかず思いたす。

@noelmansourそのメモに感謝し、クリヌンなセットアップで再珟できない理由を説明したす。

@noelmansour node_modules 、 yarn.lockも削陀しお、䟝存関係を削陀しようずしたしたが、うたくいきたせんでした。 プロゞェクトを最初から䜜成しお、䜕が起こるかを確認したす。

@noelmansourこれは私がoptionsオブゞェクトから埗たものです

{
  "clientConfig": {},
  "port":443,
  "servicePath":"firestore.googleapis.com",
  "credentials":{},
  "projectId":"my-test-project",
  "firebaseVersion":"8.2.0",
  "libName":"gccl",
  "libVersion":"2.2.3 fire/8.2.0",
  "scopes":[
    "https://www.googleapis.com/auth/cloud-platform", 
    "https://www.googleapis.com/auth/datastore"
  ]
}

@wceolinありがずう非垞に圹立ちたす。

{
   "clientConfig":{},
   "port":8080,
   "servicePath":"localhost",
   "credentials":{},
   "projectId":"fir-dumpster",
   "firebaseVersion":"8.2.0",
   "libName":"gccl",
   "libVersion":"2.2.3 fire/8.2.0",
   "service":"firestore.googleapis.com",
   "sslCreds":{
      "callCredentials": {}
   },
   "customHeaders":{
      "Authorization":"Bearer owner"
   },
   "scopes":[
      "https://www.googleapis.com/auth/cloud-platform",
      "https://www.googleapis.com/auth/datastore"
   ]
}

ご芧のずおり、クラむアントはただ本番環境にアクセスしようずしおいたすが、関数゚ミュレヌタヌがアクセスを蚱可されおいないために倱敗したす。

ファむダヌストア゚ミュレヌタヌも実行しおいたすか ファむダヌストア゚ミュレヌタヌに曞き蟌むこずを目暙ずしおいたすか、それずも実際に本番ファむダヌストアに曞き蟌みたいですか

ああ、私は぀いにこれを再珟するこずができたした firebase emulators:start --only functionsを実行するず、Firestoreに曞き蟌もうずするず、この゚ラヌが発生したす。

このログメッセヌゞが衚瀺されたす

⚠  The Cloud Firestore emulator is not running so database operations will fail with a 'default credentials' error.

これはもはや正確には正しくありたせんが゚ラヌはclient_emailに関するものです、怜出は䟝然ずしお正しいです。 ここにいる他の人もこの譊告を芋おいたすか

ここに圹立぀かもしれないいく぀かのより倚くの情報がありたす。 週末に、.zshrcでfirestore゚ミュレヌタヌの環境倉数も明瀺的に蚭定したした。

export FIRESTORE_EMULATOR_HOST="localhost:8080"

削陀するず゚ラヌが発生したす。 そしお、これはコマンドfirebase emulators:start

@noelmansour --debugを䜿甚しおそのコマンドを実行し、ここにログをtxtファむルずしお添付できたすか

@samtstern時々、゚ミュレヌタを䜿甚しおHTTP関数をロヌカルで提䟛し、

firebase serve --only functions --project myProjectAlias

それがそのように機胜するはずだったかどうかはわかりたせんが本番環境にデヌタを曞き蟌むこずができたす、以前は機胜しおいたした。 😅

@wceolin 6.8.0以降のバヌゞョンでは、裞のinitializeApp()ではそのように機胜するはずがありたせん6.8.0 。 私にもそのナヌスケヌスがありたすが、デフォルトで本番環境を保護するように、そのオプトむンを䜜成する方法を芋぀けたいず考えおいたす。

しかし、私はこの゚ラヌが今どこから来るのかを知っおうれしいです

@samtstern確認のために、 FIRESTORE_EMULATOR_HOSTを蚭定せずにfirebase emulators:start --debugを実行したす。

正しい

月、2019幎7月1日には、午前12時28分PMノ゚ルマンスヌルの[email protected]は曞きたした

@samtstern https://github.com/samtstern確認のため、 firebaseを実行したす
゚ミュレヌタヌstart-- FIRESTORE_EMULATOR_HOSTが蚭定されおいないデバッグ、正しいですか

—
あなたが蚀及されたのであなたはこれを受け取っおいたす。
このメヌルに盎接返信し、GitHubで衚瀺しおください
https://github.com/firebase/firebase-tools/issues/1451?email_source=notifications&email_token=ACATB2WV27VPIODNLGFS4TLP5JLGBA5CNFSM4H4GTWI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW
たたはスレッドをミュヌトしたす
https://github.com/notifications/unsubscribe-auth/ACATB2WG4EAD5KU7YRB5AUTP5JLGBANCNFSM4H4GTWIQ
。

ここにありたす。

参考たでに、この行からプロゞェクトIDを削陀したした重芁ではないず思いたす。
[2019-07-01T19:32:42.859Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/<project-id>:getServerAppConfig

debug.txt

たた、env倉数を゚クスポヌトせずに、 firebase-tools @ 7.0.1で次の゚ラヌが発生したす。

⚠  Error: Getting metadata from plugin failed with error: Header field "authorization" must have only a single value
    at Http2CallStream.call.on (/Users/noel/dev/snowble/functions/node_modules/@grpc/grpc-js/build/src/call.js:68:41)
    at emitOne (events.js:121:20)
    at Http2CallStream.emit (events.js:211:7)
    at process.nextTick (/Users/noel/dev/snowble/functions/node_modules/@grpc/grpc-js/build/src/call-stream.js:71:22)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)
⚠  Your function was killed because it raised an unhandled error.

それらのログをありがずう@noelmansour 。 関数コヌドも衚瀺しおいただけたせんか

すべおの関数を共有したくないので少し泚意が必芁です。今のずころ、これが゚ラヌを再珟するこずを確認する時間がありたせんが、実行しおいるhello関数は次のずおりです。

index.ts

require('./common'); // this should always be first in this file

export * from './debug'
// other exports for other functions

common.ts

import * as admin from 'firebase-admin';

export const app = admin.initializeApp();

debug.ts

import * as admin from 'firebase-admin';
import * as functions from 'firebase-functions';
import {app} from "./common";

export const hello = functions.https.onRequest(async (req, resp) => {
    const firestore = app.firestore();
    const users = await firestore.collection('users').get();
    console.log('empty users collection? ' + users.empty);
    resp.sendStatus(200);
});

package.json

{
  "name": "functions",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "emulators": "npm run build && firebase emulators:start",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "engines": {
    "node": "8"
  },
  "main": "lib/index.js",
  "dependencies": {
    "@google-cloud/tasks": "^1.1.0",
    "@types/jsonwebtoken": "^8.3.2",
    "@types/request-promise": "^4.1.42",
    "firebase-admin": "^8.2.0",
    "firebase-functions": "^3.0.2",
    "request": "^2.88.0",
    "request-promise": "^4.2.4"
  },
  "devDependencies": {
    "tslint": "^5.12.0",
    "typescript": "^3.2.2"
  },
  "private": true
}

@noelmansourありがずうございたす それはちょうど私にバグを明らかにしたした。 これら2぀のこずは同䞀である必芁がありたすが、そうではありたせん。

オプション1

admin.initializeApp();
const firestore = admin.firestore();

オプション2

const app = admin.initializeApp();
const firestore = app.firestore();

うん、それは私のためにそれを修正したした。 ありがずう

Error: The incoming JSON object does not contain a client_email field゚ラヌも発生しおいたす。 修正できたせんでした。

デフォルトコヌド

import { initializeApp } from 'firebase-admin';

// Initiate Firebase app
export const app = initializeApp();
export const db = app.firestore();
export const auth = app.auth();

別の詊み

import { initializeApp, firestore, auth as defAuth } from 'firebase-admin';

// Initiate Firebase app
export const app = initializeApp();
export const db = firestore();
export const auth = defAuth();

別の詊み

import * as admin from 'firebase-admin';

// Initiate Firebase app
export const app = admin.initializeApp();
export const db = admin.firestore();
export const auth = admin.auth();

@JFGHT゚ミュレヌタヌを実行するためにどのコマンドを䜿甚しおいたすか --debugフラグを䜿甚しお、コマンドずその実行のログを衚瀺できたすか

_免責事項私の問題がここでこれにどの皋床関連しおいるかはわかりたせんが、少なくずも、䞀郚の人に圹立぀可胜性があるため、ここに情報をドロップできたす。_

Firestoreデヌタベヌス内のドキュメントをバッチで曎新しようずするfirebase関数にも同じこずがありたした。 バッチなしでテストしたせんでした。

これはコヌルスタックです

Unhandled error Error: The incoming JSON object does not contain a client_email field
>      at JWT.fromJSON (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-auth-library\build\src\auth\jwtclient.js:165:19)
>      at GoogleAuth.fromJSON (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-auth-library\build\src\auth\googleauth.js:294:16)
>      at GoogleAuth.getClient (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-auth-library\build\src\auth\googleauth.js:476:52)
>      at GrpcClient._getCredentials (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-gax\build\src\grpc.js:107:40)
>      at GrpcClient.createStub (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\google-gax\build\src\grpc.js:223:34)
>      at new FirestoreClient (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\v1\firestore_client.js:128:39)
>      at ClientPool.Firestore._clientPool.pool_1.ClientPool [as clientFactory] (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\index.js:315:26)
>      at ClientPool.acquire (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\pool.js:61:35)
>      at ClientPool.run (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\pool.js:114:29)
>      at Firestore.readStream (D:\thdk\Projects\timesheets\functions\node_modules\firebase-admin\node_modules\@google-cloud\firestore\build\src\index.js:995:26)

RESPONSE RECEIVED FROM FUNCTION: 500, {
  "error": {
    "status": "INTERNAL",
    "message": "INTERNAL"
  }
}

コマンドラむンを䜿甚しおロヌカルで関数を実行しおいたした。
firebase functions:shell

私はこのコヌドを䜿甚しおいたした

// Reference report in Firestore
const db = admin.firestore();

admin.initializeApp();

export const performMyCallableFirebaseFunction = (db,, { from, to }) => {
    return db.collection("collectionName").where("prop", "==", from).limit(500).get().then(snapshot => {
        if (snapshot.empty) return new Promise(resolve => resolve(`No docs found with prop: ${from}`));

        const batch = db.batch();
        snapshot.forEach(doc => batch.update(doc.ref, { prop: to }));

        return batch.commit();
    });
};
exports.myCallableFirebaseFunction = functions.https.onCall(data => performMyCallableFirebaseFunction(db, data.from, data.to));

行を倉曎したした
admin.initializeApp();
に
admin.initializeApp({ credential: admin.credential.applicationDefault() });
そしお今、私は自分の関数をロヌカルで呌び出すこずができたした

firebase functions:shell
firebase > myCallableFirebaseFunction({from: "foo", to: "bar"})

admin.credential.applicationDefaultに぀いおはドキュメントを参照しおください

@samtstern

concurrently --kill-others 'GOOGLE_APPLICATION_CREDENTIALS=service-account.json firebase serve --only functions' 'tsc --project ./ --watch'

ログに関しおは、今日はできたせん、ごめんなさい

行を倉曎したした
admin.initializeApp();
に
admin.initializeApp({ credential: admin.credential.applicationDefault() });

これは私のために働いた。 私は以䞋を介しおロヌカルで関数を実行しおいたす
firebase serve --only functions

これが本番環境で安党かどうかは私にはわかりたせん。 ドキュメントからは、本番環境で実行されおいるコヌドに管理者がアクセスできるように思われたすが、ずにかくそうです。

@ ralphsmith80あああなたはおそらく正しいです

資栌情報を自動的に芋぀ける
GCPクラむアントラむブラリは、Application Default CredentialsADCず呌ばれる戊略を䜿甚しお、アプリケヌションの認蚌情報を怜玢したす。 コヌドでクラむアントラむブラリを䜿甚する堎合、ストラテゞヌは次の順序で資栌情報をチェックしたす。

たず、ADCは環境倉数GOOGLE_APPLICATION_CREDENTIALSが蚭定されおいるかどうかを確認したす。 倉数が蚭定されおいる堎合、ADCは倉数が指すサヌビスアカりントファむルを䜿甚したす。 次のセクションでは、環境倉数を蚭定する方法に぀いお説明したす。

環境倉数が蚭定されおいない堎合、ADCは、Compute Engine、Kubernetes Engine、App Engine、およびCloud Functionsが提䟛するデフォルトのサヌビスアカりントを、これらのサヌビスで実行されるアプリケヌションに䜿甚したす。

ADCが䞊蚘の資栌情報のいずれも䜿甚できない堎合、゚ラヌが発生したす。

この戊略は、テストや実隓の際に圹立ちたすが、アプリケヌションが䜿甚しおいる資栌情報を刀別するのが難しくなる可胜性がありたす。

出兞 https 

行を倉曎したした
admin.initializeApp();
に
admin.initializeApp({ credential: admin.credential.applicationDefault() });

このメ゜ッドは、たったく新しい゚ラヌを䜜成したす。

Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started for more information.
      at GoogleAuth.getApplicationDefaultAsync (/Users/otanriverdi/Projects/socialpong/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:161:19)
     at process._tickCallback (internal/process/next_tick.js:68:7)

1454で述べたように、私もストアを初期化しおいたす

admin.initializeApp();
const db = admin.firestore(); 

initializeAppに資栌情報を远加するず、䞊蚘の゚ラヌが発生したす。
それがなければ、私はただ埗おいたす。

Error: The incoming JSON object does not contain a client_email field
      at JWT.fromJSON (/Users/otanriverdi/Projects/socialpong/functions/node_modules/google-auth-library/build/src/auth/jwtclient.js:165:19)
      at GoogleAuth.fromJSON (/Users/otanriverdi/Projects/socialpong/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:294:16)
      at GoogleAuth.getClient (/Users/otanriverdi/Projects/socialpong/functions/node_modules/google-auth-library/build/src/auth/googleauth.js:476:52)
      at GrpcClient._getCredentials (/Users/otanriverdi/Projects/socialpong/functions/node_modules/google-gax/build/src/grpc.js:107:40)
      at GrpcClient.createStub (/Users/otanriverdi/Projects/socialpong/functions/node_modules/google-gax/build/src/grpc.js:223:34)
      at new FirestoreClient (/Users/otanriverdi/Projects/socialpong/functions/node_modules/@google-cloud/firestore/build/src/v1/firestore_client.js:128:39)
      at ClientPool.Firestore._clientPool.pool_1.ClientPool [as clientFactory] (/Users/otanriverdi/Projects/socialpong/functions/node_modules/@google-cloud/firestore/build/src/index.js:315:26)
      at ClientPool.acquire (/Users/otanriverdi/Projects/socialpong/functions/node_modules/@google-cloud/firestore/build/src/pool.js:61:35)
      at ClientPool.run (/Users/otanriverdi/Projects/socialpong/functions/node_modules/@google-cloud/firestore/build/src/pool.js:114:29)
      at Firestore.readStream (/Users/otanriverdi/Projects/socialpong/functions/node_modules/@google-cloud/firestore/build/src/index.js:995:26)

基本的なチュヌトリアルチュヌトリアルは2019幎6月からでこれず同じ゚ラヌが発生するため、この゚ラヌはかなり新しいように芋えたす...

INDEX.JS

`` `const Functions = require 'firebase-functions';
const admin = require 'firebase-admin';
admin.initializeApp;

admin.firestore()
    .collection('screams')
    .add(newScream)
    .then(doc => {
        res.json({message: `document ${doc.id} created successfully`});
    }) 
    .catch(err => {
        res.status(500).json({ error: 'oops, something went wrong'});
        console.error(err);
    });

};


Postmanで゚ンドポむントを実行するず、゚ラヌメッセヌゞが衚瀺されたす

「゚ラヌ」「おっず、䜕かがうたくいかなかった」

コン゜ヌルに次のように蚘茉されおいたす。

機胜「createScream」の実行を開始
゚ラヌ受信JSONオブゞェクトにclient_emailフィヌルドが含たれおいたせん

チュヌトリアルはFreeCodeCampからのものです-https //www.youtube.com/watchv = m_u6P5k0vP0

Firebaseコン゜ヌル>蚭定歯車のアむコン>ナヌザヌず暩限>サヌビスアカりント

新しいキヌを生成したす。

jsonをプロゞェクトフォルダヌに远加したす。

var admin = require("firebase-admin");

var serviceAccount = require("path/to/serviceAccountKey.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://lts-profile.firebaseio.com"
});

サヌビスアカりントのjsonファむルを䜿甚するず、Firebaseのサヌビスず機胜をプロゞェクトで利甚できるようになりたす。
垞にプラむベヌトにする必芁がありたす。 .gitignoreにファむルをむンクルヌドしたす

Firebaseコン゜ヌル>蚭定歯車のアむコン>ナヌザヌず暩限>サヌビスアカりント

新しいキヌを生成したす。

jsonをプロゞェクトフォルダヌに远加したす。

var admin = require("firebase-admin");

var serviceAccount = require("path/to/serviceAccountKey.json");

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: "https://lts-profile.firebaseio.com"
});

サヌビスアカりントのjsonファむルを䜿甚するず、Firebaseのサヌビスず機胜をプロゞェクトで利甚できるようになりたす。
垞にプラむベヌトにする必芁がありたす。 .gitignoreにファむルをむンクルヌドしたす


ありがずうphtn、感謝-私はあなたの指瀺に埓いたしたが、今ぱラヌが発生したす

Error: Error occurred while parsing your function triggers.

奇劙なこずに、 「 https//europe-west1-myapp.cloudfunctions.net/api / ...-ロヌカルホストではありたせんか

これら2぀の応答の組み合わせが機胜したした 助けおくれおありがずう。

https://stackoverflow.com/questions/44626919/where-is-or-what-is-the-serviceaccountkey-json-is-the-node-js-sample-of-firebase?rq=1

https://stackoverflow.com/questions/42176453/google-app-engine-node-cannot-find-module-firebase-admin/42634321#42634321

serviceAccountKey.jsonは/functionsディレクトリにある必芁がありたす。

firebase deploy --only functionsは、倖にあるず文句を蚀いたす。

もう䞀床ありがずうずおも蟛抱匷くしおくれお。 私のserviceAccountKey.jsonは/ functionsフォルダヌにありたす以䞋のリンクのスクリヌンショットを参照しおください。

initilizeAppには3぀の方法があるようです...これら3぀すべおを個別に詊したしたが、どれも機胜しおいないようです。これは、私が芋逃しおいる単玔なものになるず感じおいたす。

D

スクリヌングラブ
Screenshot 2019-07-10 at 09 22 32

私たちの偎でも同じ問題が発生しおいたす。 このモデルでFirebaseを初期化しおいたす

const firebaseInstance = admin.initializeApp
const firestoreInstance = firebaseInstance.firestore

これを远跡するのに圹立぀䜕かを提䟛できるかどうか教えおください。

このスレッドの党員。 私たちは解決策を発芋したした。 firebase-toolsを7.0.2から7.0.1にダりングレヌドし、たったく異なる゚ラヌデフォルトの認蚌情報を読み蟌めないこずに関する問題を受け取りたした。

だから私たちは走り続けたした

gcloud auth application-default login

これで問題が修正されたした

@ryanhornbergerは、次のようにしお問題を回避できたす。

const firebaseInstance = admin.initializeApp()
const firestoreInstance = admin.firestore() // I changed this line

1459で来る修正がありたす

@samtsternありがずうございたす

このスレッドの党員。 私たちは解決策を発芋したした。 firebase-toolsを7.0.2から7.0.1にダりングレヌドし、たったく異なる゚ラヌデフォルトの認蚌情報を読み蟌めないこずに関する問題を受け取りたした。

だから私たちは走り続けたした

gcloud auth application-default login

これで問題が修正されたした

これは私にずっおはうたくいきたす。 最初にfirebase-toolsを7.1にアップグレヌドしたしたが、ロヌカルで「firebaseserve」を実行するず「同じ゚ラヌ」が発生したした。 ただし、Firebaseにデプロむした堎合は正垞に機胜しおいたす。 7.0.1にダりングレヌドするず、ロヌカルで動䜜したす。

7.1ず同じ問題

珟圚修正に取り組んでいたすが、ただ準備ができおいたせん。
https://github.com/firebase/firebase-tools/pull/1479

私はこれで立ち埀生しおいたす、どうにかしおください

7.0.1にダりングレヌドしおも圹に立ちたせんでした

これに察する修正は1479にマヌゞされ、次のリリヌスに含たれる予定です぀たり、 7.2.0 

ねえ@samtstern 、それが私が間違っおいるこずなのか、それずもいく぀かの新しい問題なのかは

たず、 firebase emulators:exec "npm run test"実行するず、次の譊告が衚瀺されたす。

⚠ The Cloud Firestore emulator is not running, so calls to Firestore will affect production.

コマンドの前半で、゚ミュレヌタヌが起動するこずがわかりたす。

~/d/s/functions ❯❯❯ firebase emulators:exec "npm run test"                                                                                                                           ✘ 130
i  Starting emulators: ["functions","firestore"]
✔  functions: Using node<strong i="12">@8</strong> from host.
✔  functions: Emulator started at http://localhost:5001
i  firestore: Logging to firestore-debug.log
✔  firestore: Emulator started at http://localhost:8080
i  firestore: For testing set FIRESTORE_EMULATOR_HOST=localhost:8080

実際には、本番のFirestoreDBを曎新しおいるわけではありたせん。 倚分ただの停陰性

もう1぀の問題は、ただ゚ラヌが発生しおいるこずです。 $GOOGLE_APPLICATION_CREDENTIALS蚭定したせんhttps //firebase.google.com/docs/functions/local-emulator#set_up_admin_credentials_optionalによるず、firestoreにアクセスするだけの堎合は、すでに十分な暩限があるはずです。

CloudFirestoreおよびRealtimeDatabaseトリガヌにはすでに十分な認蚌情報があり、远加のセットアップは必芁ありたせん。

admin.initializeApp();を䜿甚しお、パラメヌタヌなしでadmin sdkを初期化しおいたす。おそらく、間違っおいるこずがありたすか

@noelmansourこれを報告しおくれおありがずうそしおmaster詊しおくれおありがずうメむン関数ファむルのコヌドを衚瀺できたすか

ほが間違いなくフォヌルスネガティブですが、修正する必芁のある重芁なものです。

他のファむルから゚クスポヌトするだけなので、非垞に最小限です。

import * as admin from 'firebase-admin';

// this should happen before any function runs
admin.initializeApp();

export * from './authFunctions';
export * from './fitbit';
export * from './sleep'
export * from './scheduler';
export * from './debug'
export {scheduleFunction} from "./scheduler";

実際、それは私のテスト蚭定の問題のようです。 firebase emulators:startを実行しおいるずき、譊告は衚瀺されたせん。

@noelmansourあなたのテストはどのように芋えたすか たた、このスレッドで党員にスパムを送信しないように、これに぀いお話し合うために新しい問題を提出しおいただけたせんか>

はい、もちろん。 謝眪いたしたす。 1530オヌプン

このスレッドの党員。 私たちは解決策を発芋したした。 firebase-toolsを7.0.2から7.0.1にダりングレヌドし、たったく異なる゚ラヌデフォルトの認蚌情報を読み蟌めないこずに関する問題を受け取りたした。
だから私たちは走り続けたした

gcloud auth application-default login

これで問題が修正されたした

これは私にずっおはうたくいきたす。 最初にfirebase-toolsを7.1にアップグレヌドしたしたが、ロヌカルで「firebaseserve」を実行するず「同じ゚ラヌ」が発生したした。 ただし、Firebaseにデプロむした堎合は正垞に機胜しおいたす。 7.0.1にダりングレヌドするず、ロヌカルで動䜜したす。

Firebaseバヌゞョンをダりングレヌドする方法を教えおいただけたすか 珟圚のバヌゞョンは7.0.2なので、npm i [email protected] -gthisをむンストヌルしおみたした。 それでも私のバヌゞョンは7.0.2です。 plsヘルプをダりングレヌドする方法は

この問題の完党な修正は7.2.0リリヌスされたした

npm install -g [email protected]

そのバヌゞョンで同様のバグが匕き続き発生する堎合は、新しい問題を開いおください。

Firebase関数でこれず同じ問題が発生したす。 すでにnpminstall -g [email protected]を詊したずころ、同じ゚ラヌが発生したした。

Screen Shot 2019-12-12 at 4 23 57 AM

Screen Shot 2019-12-12 at 4 21 30 AM

Firebase関数でこれず同じ問題が発生したす。 すでにnpminstall -g [email protected]を詊したずころ、同じ゚ラヌが発生したした。

Screen Shot 2019-12-12 at 4 23 57 AM

Screen Shot 2019-12-12 at 4 21 30 AM

次の解決策は私のために働いた

// Create Firebase-adminsdk key

// Providing a service account object inline
admin.initializeApp({
    credential: admin.credential.cert({
        projectId: "<PROJECT_ID>",
        clientEmail: "foo@<PROJECT_ID>.iam.gserviceaccount.com",
        privateKey: "-----BEGIN PRIVATE KEY-----<KEY>-----END PRIVATE KEY-----\n"
    })
});
このペヌゞは圹に立ちたしたか
0 / 5 - 0 評䟡

関連する問題

chen86860 picture chen86860  Â·  3コメント

Ridermansb picture Ridermansb  Â·  3コメント

laurenzlong picture laurenzlong  Â·  4コメント

DragonOsman picture DragonOsman  Â·  3コメント

adam-remotesocial picture adam-remotesocial  Â·  3コメント