I use django rest framework and token auth as a backend auth. From backend token comes as this format
{token: “cKCxxxxxxxxxxxxxxxxxxxxx”}
on the frontend ember-simple auth i use oauth2 as a authenticator when i try to login it says:
The authenticator “authenticator:oauth2” rejected to restore the session - invalidating…
and session is not saved it logged in but when the route change it logged out. How do i append token in headers? It has to be appended automatically when use ember-simple-auth right or i get that wrong???
login.js
actions: {
authenticate(username, password) {
var controller = this.controller;
this.get('session').authenticate('authenticator:oauth2', username, password).catch((reason) => {
controller.set('errorMessage', reason.detail || reason);
console.log(this.get('session.data.authenticated'));
});
}
}
and authenticator:
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';
export default OAuth2PasswordGrant.extend({
serverTokenEndpoint: 'http://127.0.0.1:8000/api/auth/login/',
});
authorizer:
import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer';
export default OAuth2Bearer.extend({
});
adapter:
import DS from 'ember-data';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
export default DS.RESTAdapter.extend(DataAdapterMixin, {
host: 'http://127.0.0.1:8000',
namespace: 'api',
authorizer: 'authorizer:oauth2',
});