我跟着小天真的'在项目自述文件中实现:https://github.com/mondora/asteroid-oauth-mixin
我的代码与示例的唯一区别在于将箭头功能更改为传统功能。
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(' google')
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 :(得分:0)
我需要meteor add service-configuration
并设置我的configure-accounts.js并为该应用创建一个google clientId。
这让我有了一个弹出窗口,可以选择要授权的用户。然后我收到一个关于目标原点不匹配的新错误,但我打算将此问题解决为已解决。