Ember-cli-simple-auth not sending token


#1

So, using ember-cli-simple-auth and ember-cli-simple-auth-token. I am able to authenticate fine and access the session (I can display session.token in any of my views once logged in), but I am not seeing the ‘Authorization’ header being set on requests to my server. I have in my config:

  ENV['simple-auth'] = {
     authorizer: 'simple-auth-authorizer:token',
     authenticationRoute: 'login',
     routeAfterAuthentication: '/'
  };

  ENV['simple-auth-token'] = {
     identificationField: 'email',
     serverTokenEndpoint: 'http://localhost:3000/users/compare',
     tokenPropertyName: 'token',
     authorizationPrefix: 'Bearer ',
     authorizationHeaderName: 'Authorization',
     headers: {}
  };

I’m working with the versions:

"ember-cli-simple-auth": "^0.8.0"
"ember-cli-simple-auth-token": "^0.7.3"

Am i using a deprecated version because ember-cli-simple-auth-token only will work with him, and currently i need this.

My token is exactly in: this.get('session.content.secure.token')

Thanks for help.


#2

had to write my custom authorizer:

import Base from 'ember-simple-auth/authorizers/base';
export default Base.extend({
  authorize(sessionData, block) {
   block('Authorization', 'Token ' + sessionData.token);
  }
});

Regards, Martin


#3

Hei Martin, thanks for your faster reply. Where should i put this code??

Thank you.


#4

Mine lives in app/authorizers/custom.js - but this depends from your configuration. So I refer to him this way: ENV[‘simple-auth’] = { authorizer: ‘authorizer:custom’, … }