# Django rest + ember simple auth The authenticator "authenticator:oauth2" rejected to restore the session - invalidating…

**URL:** <https://discuss.emberjs.com/t/django-rest-ember-simple-auth-the-authenticator-authenticator-oauth2-rejected-to-restore-the-session-invalidating/11144>\
**Category:** Uncategorized\
**Created:** [July 13, 2016, 5:56am UTC](https://discuss.emberjs.com/t/django-rest-ember-simple-auth-the-authenticator-authenticator-oauth2-rejected-to-restore-the-session-invalidating/11144 "2016-07-13T05:56:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zorig](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/zorig/32/12608_2.png) [@Zorig](https://discuss.emberjs.com/u/Zorig)\
**Post date:** [July 13, 2016, 5:56am UTC](https://discuss.emberjs.com/t/django-rest-ember-simple-auth-the-authenticator-authenticator-oauth2-rejected-to-restore-the-session-invalidating/11144/1 "2016-07-13T05:56:02Z")

</div>

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

```auto
  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:

```auto
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:

```auto
import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer';

export default OAuth2Bearer.extend({
});

```

adapter:

```auto
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',
});

```
