Hey there! I’ve been trying to use ember-simple-auth
to authenticate with my Django backend.
I have the following answer from the backend server:
HTTP/1.1 200 OK
Allow: POST, OPTIONS
Content-Length: 165
Content-Type: application/json
Date: Fri, 14 Aug 2020 00:46:09 GMT
Server: WSGIServer/0.2 CPython/3.6.9
Vary: Origin
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
{
"acess_token": "xxxx",
"email": "xxx@gmail.com",
"fullname": "xxxxx",
"token_type": "bearer",
"user_id": 1
}
And still I get this error on my Ember app:
access_token is missing in server response
This is my application adapter:
//app/adapters/application.js
import JSONAPIAdapter from '@ember-data/adapter/json-api';
import ENV from 'gestao-hotelaria-dashboard/config/environment';
export default class ApplicationAdapter extends JSONAPIAdapter {
host = ENV.APP.api;
@service session;
handleResponse(status) {
if (status === 401 && this.get('session.isAuthenticated')) {
this.session.invalidate();
}
return this._super(...arguments);
}
}
And this is my login-form component:
//app/components/login-form.js
import Component from '@glimmer/component';
import {
inject as service
} from '@ember/service';
import {
action
} from "@ember/object";
import {
tracked
} from "@glimmer/tracking";
export default class LoginFormComponent extends Component {
@service session;
@tracked identification;
@tracked password;
@tracked rememberMe;
@action
async authenticateWithOAuth2() {
try {
let {
identification,
password
} = this;
await this.session.authenticate('authenticator:oauth2', identification, password);
if (this.rememberMe) {
this.session.set('store.cookieExpirationTime', 60 * 60 * 24 * 14);
}
} catch (error) {
debugger;
}
if (this.session.isAuthenticated) {
debugger;
// What to do with all this success?
}
}
@action
updateIdentification(e) {
this.identification = e.target.value;
}
@action
updatePassword(e) {
this.password = e.target.value;
}
@action
updateRememberMe(e) {
this.rememberMe = e.target.checked;
}
}
I am using the "ember-simple-auth": "^3.0.0",
, “ember-data”: “~3.18.0” and "ember-cli": "~3.18.0",
.
Does somebody know what could be happening? I couldn’t figure out what’s wrong with my Ember app.
Thank you.