Hi People,
Im using Ember-Auth and have login to my rails application working.
Once logged in the auth.auth-token is set and i can view it in my templates with:
{{auth.authToken}}
I no need to pass this token along with my ember-data requests but for the life of me cant figure out how to access it within the adapter.
App.Store = DS.Store.extend
adapter: DS.RESTAdapter.reopen
namespace: 'api/v1'
setHeaders: (->
this.set('headers', { "auth_token": <what goes here?> });
return
).on('init');
some of the things I’ve tried:
App.Session.get("authToken")
App.auth_token
App.auth.auth_token
App.Auth.get('auth_token')
App.Auth.get('authToken')
There seem to be lots of people doing it different ways, due to embers rapidly changing API. But everything I’ve tried ends up being undefined.
DEBUG: -------------------------------
DEBUG: Ember : 1.5.0-beta.3
DEBUG: Ember Data : 1.0.0-beta.7.f87cba88
DEBUG: Handlebars : 1.3.0
DEBUG: jQuery : 1.11.0
DEBUG: -------------------------------
Auth configuration:
App.Auth = Ember.Auth.extend
request: 'jquery'
response: 'json'
strategy: 'token'
session: 'cookie'
signInEndPoint: '/api/v1/user_session' # api url for sign-in
signOutEndPoint: '/api/v1/user_session' # api url for sign-out
tokenKey: 'auth_token' # param returned from api containing auth token
tokenIdKey: 'user_id' # param returned from api for id of authenticated user
tokenLocation: 'param' # auth token will be sent to api as a param
Ive also posted this on stackoveflow, thought this might be a better place, will update SO with the answer.