2015-09-08 147 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