jeudi 5 février 2015

Ember Simple Auth (with token plugin) won't add the Authorization header with the token

I had a simple and working application with Ember CLI 0.1.12. I use the Ember Simple Auth addon with the Token authenticator and authorizer. http://ift.tt/1CnPZzM


First, I wasn't able to authenticate, because I had no idea what the server was supposed to return. After a lot of googling, I was able to figure out that the server should return something like this:


{ "access_token": "ToKeN123hEre" }


Now I was able to authenticate and sessions work. But when I make other calls, the Authorization header doesn't appear in the request headers, so it's impossible for the server to know the token.


This is what I have tried so far:


Setting my environment.js file:



ENV['simple-auth'] = {
crossOriginWhitelist: ['*'],
authorizer: 'simple-auth-authorizer:token',
routeAfterAuthentication: '/chatrooms/1'
};

ENV['simple-auth-token'] = {
serverTokenEndpoint: '/api0/auth',
identificationField: 'username',
passwordField: 'password',
tokenPropertyName: 'token',
authorizationPrefix: 'Bearer ',
authorizationHeaderName: 'Authorization',
headers: {}
};


Make my server use CORS and allow the Authentication header and requests from any Origin.





Aucun commentaire:

Enregistrer un commentaire