简单的ember-cli-simple-auth和oauth2项目

时间:2015-01-27 22:48:05

标签: authentication ember.js oauth-2.0 ember-cli ember-simple-auth

我对第三方身份验证非常陌生,并且无法通过与simple-auth-oauth2配对的ember-cli-simple-auth插件向LinkedIn发出API请求。我的environment.js位于下方,我试图将简单实验室的部件拼凑起来。 introduction1和http://ember-simple-auth.com/ember-simple-auth-api-docs.html1,特别是在环境的底部===' test'。在构建CLI项目后我没有收到任何错误,但我确实在浏览器的控制台(不是警告或错误)中收到了一条通知:

No authorizer was configured for Ember Simple Auth - specify one if backend requests need to be authorized.

现在,我只是想从LinkedIn获取一个身份验证令牌,我不确定下一步是什么。如果我试图触发"验证"我的登录控制器上的操作(扩展loginControllerMixin),我在控制台中收到错误说:

Uncaught Error: Assertion Failed: No authenticator for factory "authenticator:simple-auth-oauth2" could be found

我错过了哪些部分?


Environment.js:

// config/environment.js
/* jshint node: true */

module.exports = function(environment) {
  var ENV = {
    modulePrefix: 'seminars-me',
    environment: environment,
    baseURL: '/',
    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
}


 };

  if (environment === 'development') {
    // ENV.APP.LOG_RESOLVER = true;
    // ENV.APP.LOG_ACTIVE_GENERATION = true;
    // ENV.APP.LOG_TRANSITIONS = true;
    // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
    // ENV.APP.LOG_VIEW_LOOKUPS = true;
  }

  if (environment === 'test') {
    // Testem prefers this...
    ENV.baseURL = '/';
    ENV.locationType = 'none';

// keep test console output quieter
ENV.APP.LOG_ACTIVE_GENERATION = false;
ENV.APP.LOG_VIEW_LOOKUPS = false;

ENV.APP.rootElement = '#ember-testing';

ENV['simple-auth-oauth2'] = {
  serverTokenEndpoint: 'https://www.linkedin.com/uas/oauth2/authorization?response_type=code&client_id=757ll7ci1xd93u&scope=profile'
};
    ENV['simple-auth'] = {
      authorizer: 'simple-auth-authorizer:oauth2-bearer',
      crossOriginWhitelist: ['https://www.linkedin.com'],
      store: 'simple-auth-session-store:local-storage'
    };
  }

  if (environment === 'production') {

  }

  return ENV;
};

1 个答案:

答案 0 :(得分:3)

当您使用simple-auth-authenticator:oauth2-password-grant时,验证者实际上已注册为authenticator:simple-auth-oauth2