2017-09-20 22 views
0

我已經按照項目自述的「天真」的實現:https://github.com/mondora/asteroid-oauth-mixin小行星的Oauth loginServiceConfiguration:「谷歌」的未定義

在我的代碼示例中的唯一差別是改變箭頭功能,傳統的這個用法。

asteroid.ddp.on("added", ({collection, id, fields}: { collection: string; fields: {}, id: string }) => { 
    if (collection === "meteor_accounts_loginServiceConfiguration") { 
    asteroid.loginServiceConfiguration = { 
     ...asteroid.loginServiceConfiguration, 
     [id]: { 
     _id: id, 
     ...fields 
     } 
    }; 
    } 
}); 
}); 
asteroid.getServiceConfig = function(providerName: string) { // ts file 
    return this.loginServiceConfiguration[providerName]; 
} 

當我做asteroid.loginWith( '谷歌')

index.ts:50 Uncaught TypeError: Cannot read property 'google' of undefined 

在流星後端我也裝meteor add accounts-base accounts-google,因爲我認爲這是一種依賴。

我錯過了什麼?謝謝!


我試着加入DDP.loginServiceConfiguration = {}超過該片段解決了錯誤,但創建一個新的錯誤之前。

asteroid-oauth-mixin.js:787 Uncaught TypeError: Cannot read property 'clientId' of undefined 
    at getOauthClientId (asteroid-oauth-mixin.js:787) 
    at Object.getOptions (asteroid-oauth-mixin.js:720) 
    at Asteroid.loginWith (asteroid-oauth-mixin.js:104) 
    at LoginForm../src/routes/accounts/auth/LoginForm.tsx.LoginForm.handleLoginWithGoogle (

而且當我運行meteor mongo應該db.meteor_accounts_loginServiceConfiguration.find().count()爲0?

回答

0

我需要meteor add service-configuration並設置我的configure-accounts.js併爲應用程序創建一個google clientId。

這讓我有點彈出窗口,並可以選擇要授權的用戶。然後我收到一個關於目標原點不匹配的新錯誤,但我將按照解決方法關閉此問題。