Passing a jwt to my REST adapter

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

My API is written in Nodejs.

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.

1 Like

@square The recommended approach is to extend your data adapter with mixin provided by ember-simple-auth. More info here DataAdapterMixin - ember-simple-auth


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