Passing a jwt to my REST adapter


#1

How can I pass a json web token (jwt) with my REST Adapter.

My API is written in Nodejs.


#2

Logging in / passing tokens doesn’t really have much to do with your domain entities, so I would recommend just using a standard AJAX call to perform login.

You can add something like this property to your adapter to send your token with every request:

headers: function() {
	return {
		'X-Access-Token': this.get('session.secure.token')
	};
}.property().volatile(),

Change the header name and token path as you need to.


#3

@square The recommended approach is to extend your data adapter with mixin provided by ember-simple-auth. More info here https://ember-simple-auth.com/api/classes/DataAdapterMixin.html


I am assuming that you are using ember-simple-auth to authorize with your backend.