0

I'm trying to configure simple-auth-oauth2 for Ember app. As documentation says http://ember-simple-auth.com/ember-simple-auth-oauth2-api-docs.html

Ember Simple Auth OAuth2's configuration object.

To change any of these values, set them on the application's environment object:

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

Here is my config

//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;
};

simple-auth-oauth2 keeps using default values. It's not particularly an issue of the plugin, I tried another extension ('simple-auth-token') and faced exactly the same issue - config is not used.

Macchiatow
  • 607
  • 10
  • 24

1 Answers1

0

For https://github.com/simplabs/ember-simple-auth (I have 1.1.0 version)

You should define your authorizer in application (if use have pod structure it will be in application/authorizer.js (same issue will be with adapter.js):

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

then you can use:

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

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

your config should be in your_app_name/config/environment.js

Hubert Olender
  • 1,130
  • 9
  • 15