Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import {Authentication} from 'aurelia-auth' #137

Open
jonathaneckman opened this issue Jun 23, 2016 · 4 comments
Open

import {Authentication} from 'aurelia-auth' #137

jonathaneckman opened this issue Jun 23, 2016 · 4 comments

Comments

@jonathaneckman
Copy link

Trying to do this: import {Authentication} from 'aurelia-auth'; will give the following error:

Error: key/value cannot be null or undefined. Are you trying to inject/register something that doesn't exist with DI?

@paulvanbladel
Copy link
Owner

paulvanbladel commented Jun 23, 2016

when you look to the 'index' file (aurelia-auth.js) you will see that the Authentication class is not exported.
I guess that's the reason why you can't import it, no?

import {AuthService} from './auth-service';
import {AuthorizeStep} from './authorize-step';
import {FetchConfig} from './auth-fetch-config';
import {BaseConfig} from './base-config';
import {AuthFilterValueConverter} from './auth-filter';

export function configure(aurelia, configCallback) {
  aurelia.globalResources('./auth-filter');

  let baseConfig = aurelia.container.get(BaseConfig);
  if (configCallback !== undefined && typeof(configCallback) === 'function') {
    configCallback(baseConfig);
  }
}

export {
  AuthFilterValueConverter,
  AuthService,
  AuthorizeStep,
  BaseConfig,
  FetchConfig
};

@davidpurkiss
Copy link

Having a similar issue. The reason I am trying to import Authentication is because this is where setToken() is. How would one go about "Supplying token programmatically" without this?

@davidpurkiss
Copy link

Oh, never mind. I got it working with the following.

this.authService.auth.setToken(token, redirect);

@ShaunVanDyk
Copy link

Shouldn't Authentication be exported as part of the node_module though? The example in the docs under "What exactly is 'configured' on the Http Client and can we have multiple endpoints?" point to using the auth.TokenInterceptor so that you can configure the rest of the settings yourself, however because Authentication isn't exported we can't import { Authentication } from 'aurelia-auth'. (On that note the documentation is wrong as well as it injects AuthService into auth which doesn't contain a TokenInterceptor method).

The sample app works fine because it is using all of the files from the library in a local context, however when using the library via npm this just doesn't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants