【问题标题】:Simple ember-cli-simple-auth and oauth2 project简单的 ember-cli-simple-auth 和 oauth2 项目
【发布时间】:2015-03-26 17:12:56
【问题描述】:

我是第 3 方身份验证的新手,无法通过与 simple-auth-oauth2 配对的 ember-cli-simple-auth 插件向 LinkedIn 发出 API 请求。我的 environment.js 在下面,我尝试将 Simple Labs 的介绍 1 和 http://ember-simple-auth.com/ember-simple-auth-api-docs.html1 的部分拼凑在一起,特别是在 environment === '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;
};

【问题讨论】:

  • 您是否同时安装了ember-cli-simple-authember-cli-simple-auth-oauth2
  • @marcoow 是的,我做到了,终端没有输出任何错误

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


【解决方案1】:

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

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-07
  • 1970-01-01
  • 1970-01-01
  • 2019-09-04
  • 1970-01-01
相关资源
最近更新 更多