使用Ember CLI,使用torii工作时,我在使用简单的auth时遇到了很多麻烦 .
在创建一个新的Ember CLI应用程序并安装torii,ember-cli-simple-auth和ember-cli-simple-auth-torii后,我的登录页面上有几个按钮
这是我的routes / login.js的内容:
import Ember from 'ember';
export default Ember.Route.extend({
actions: {
googleLogin: function() {
this.get('session').authenticate('simple-auth-authenticator:torii', 'google-oauth2');
return;
},
facebookLogin: function() {
this.get('session').authenticate('simple-auth-authenticator:torii', 'facebook-oauth2');
return;
}
}
});
我的environment.js文件的相关部分是:
var ENV = {
...
torii: {
providers: {
'google-oauth2': {
apiKey: 'api-key-here',
scope: 'profile',
redirectUri: 'http://localhost:4200'
},
'facebook-oauth2': {
apiKey: 'api-key-here',
redirectUri: 'http://localhost:4200'
}
}
},
...
};
当我点击login.js中的操作时,出现以下错误:
Error: Expected configuration value providers.facebook-oauth2.apiKey to be defined!
要么
Error: Expected configuration value providers.google-oauth2.apiKey to be defined!
为什么torii没有拿起我的environment.js配置?
2 回答
你需要在facebook和google中创建应用程序,获取api密钥并将其放在你环境中的
apiKey: 'api-key-here'
中 .原来我的问题很简单,需要重启的是ember serve进程(Ctrl c,然后重新运行ember serve) .