2017-04-09 130 views
0

我目前無法使用nodejs中的firebase-admin讀取或寫入數據。無法使用firebase-admin獲取有效的Google OAuth2訪問令牌

沒有記錄打開它只是永遠掛起,永遠不會返回一個錯誤,永遠不會完成。

隨着日誌功能但是它提供了以下(繼續重試上一個腐朽的時間表 - 但具有相同的結果):

p:0: Browser went online. 
0: set {"path":"/server/saving-data/fireblog/users","value":{"alanisawesome":{"date_of_birth":"June 23, 1912","full_name":"Alan Turing"},"gracehop":{"date_of_birth":"December 9, 1906","full_name":"Grace Hopper"}},"zg":null} 
p:0: Buffering put: /server/saving-data/fireblog/users 
p:0: Making a connection attempt 
p:0: Failed to get token: Error: Credential implementation provided to initializeApp() via the "credential" property failed to fetch a valid Google OAuth2 access token with the following error: "unable to verify the first certificate". 
p:0: data client disconnected 
p:0: Trying to reconnect in 0ms 
0: onDisconnectEvents 

當我趕上(內部火力管理員)HTTPS請求我得到以下內容:

{ Error: unable to verify the first certificate 
    at TLSSocket.<anonymous> (_tls_wrap.js:1094:38) 
    at emitNone (events.js:86:13) 
    at TLSSocket.emit (events.js:188:7) 
    at TLSSocket._finishInit (_tls_wrap.js:616:8) 
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:446:38) code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE' } 

我試着從控制檯生成一個新的私鑰,但它繼續返回相同的錯誤。我還添加了require('ssl-root-cas').input(),如其他地方所建議的,但它不會改變行爲。同時將實際的json對象傳遞給admin.credential.cert函數不會改變行爲。

我目前在節點v7.7.4上。

下面是代碼我有產生錯誤:

const admin = require('firebase-admin'); 

admin.initializeApp({ 
    credential: admin.credential.cert('./serviceAccountKey.json'), 
    databaseURL: 'https://mtg-decks-bc92d.firebaseio.com' 
}); 

// turn on logging 
admin.database.enableLogging(true); 

const db = admin.database(); 
const ref = db.ref('server/saving-data/fireblog'); 

const usersRef = ref.child('users'); 
usersRef.set({ 
    alanisawesome: { 
    date_of_birth: 'June 23, 1912', 
    full_name: 'Alan Turing' 
    }, 
    gracehop: { 
    date_of_birth: 'December 9, 1906', 
    full_name: 'Grace Hopper' 
    } 
}).then(() => { 
    console.log('set complete'); 
}); 
+0

您是否能夠弄清楚這一點?我的服務器在幾天前運行良好,沒有任何代碼更新,現在我遇到了這個問題。 – arpwal

回答

相關問題