Reputation: 4060
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. https://github.com/jpadilla/ember-cli-simple-auth-token
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: '/profile'
};
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.
Upvotes: 1
Views: 1210
Reputation: 4060
I ended up changing "access_token" for simply "token", and now it works.
Upvotes: 1