2015-09-08 106 views
0

我正在尝试为Ember应用程序配置simple-auth-oauth2。如文档所述http://ember-simple-auth.com/ember-simple-auth-oauth2-api-docs.htmlEmber配置问题

Ember Simple Auth OAuth2的配置对象。

要改变的任何值,将它们设置在应用程序的 环境对象上:

ENV [ '简单-AUTH-的oauth2'] = {serverTokenEndpoint: '/一些/定制/端点'}

这里是我的配置

//config/environment.js 
module.exports = function (environment) { 
    var ENV = { 
     modulePrefix: 'ember-app', 
     environment: environment, 
     baseURL: '/', 
     API_HOST: '/', 
     locationType: 'auto', 
     EmberENV: { 
      FEATURES: { 
       // Here you can enable experimental features on an ember canary build 
       // e.g. 'with-controller': true 
      } 
     }, 

     APP: { 
      // Here you can pass flags/options to your application instance 
      // when it is created 
     } 
    }; 

    ENV['simple-auth-oauth2'] = { 
     serverTokenEndpoint: '/some/custom/endpoint' 
    }; 

    ENV['simple-auth'] = { 
     authorizer: 'simple-auth-authorizer:oauth2-bearer' 
    }; 

    return ENV; 
}; 

简单的auth-的oauth2保持使用默认值。这不是特别的插件问题,我尝试了另一个扩展('simple-auth-token'),并面对完全相同的问题 - 配置不被使用。

回答

0

对于https://github.com/simplabs/ember-simple-auth(我有1.1.0版本)

你应该在应用程序中定义的认证器(如果使用具有吊舱结构,它会在应用程序/ authorizer.js(同样的问题将与adapter.js) :

import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer'; 
export default OAuth2Bearer.extend(); 

那么你可以使用:

ENV['ember-simple-auth'] = { 
    authorizer: 'simple-auth-authorizer:oauth2-bearer' 
}; 

ENV['simple-auth-oauth2'] = { 
    serverTokenEndpoint: <your_backend_endpoint_url> 
}; 

你的配置应该是your_app_name/config/environment.js