Django rest framework 无法连接Ember简单身份验证和DRF令牌身份验证

Django rest framework 无法连接Ember简单身份验证和DRF令牌身份验证,django-rest-framework,ember-simple-auth,Django Rest Framework,Ember Simple Auth,我在Ember Simple Auth中遇到问题 我正在尝试连接我的服务器端应用程序(在Django 1.9上使用DRF)和客户端应用程序(在Ember 2.2上使用) 在服务器端,我正在上获取令牌http://localhost:8000/api-令牌身份验证“。函数需要请求中的两个参数:“用户名”和“密码”。但Ember Simple Auth发送带有参数的POST请求:“用户名[标识]”和“密码[密码]”,服务器返回“400”。我认为争论的问题是关键 我试图更改oauth2 passwo

我在Ember Simple Auth中遇到问题

我正在尝试连接我的服务器端应用程序(在Django 1.9上使用DRF)和客户端应用程序(在Ember 2.2上使用)

在服务器端,我正在
上获取令牌http://localhost:8000/api-令牌身份验证“
。函数需要请求中的两个参数:
“用户名”
“密码”
。但Ember Simple Auth发送带有参数的POST请求:
“用户名[标识]”
“密码[密码]”
,服务器返回“400”。我认为争论的问题是关键

我试图更改oauth2 password grant.js中的.authenticate方法(我无法编写自定义验证器,因为我是javascript的新手),但没有任何更改

手动POST请求返回预期答案。 请告诉我解决这个问题的方法

请原谅我的英语

authenticate(identification, password, scope = []) {
    return new RSVP.Promise((resolve, reject) => {
      const data                = { 'grant_type': 'password', username: identification, password };
      const serverTokenEndpoint = this.get('serverTokenEndpoint');
      const scopesString = Ember.makeArray(scope).join(' ');
      if (!Ember.isEmpty(scopesString)) {
        data.scope = scopesString;
      }
      this.makeRequest(serverTokenEndpoint, data).then((response) => {
        run(() => {
          const expiresAt = this._absolutizeExpirationTime(response['expires_in']);
          this._scheduleAccessTokenRefresh(response['expires_in'], expiresAt, response['refresh_token']);
          if (!isEmpty(expiresAt)) {
            response = Ember.merge(response, { 'expires_at': expiresAt });
          }
          resolve(response);
        });
      }, (xhr) => {
        run(null, reject, xhr.responseJSON || xhr.responseText);
      });
    });
  },
我的变体:

const data = { 'grant_type': 'password', 'username': identification, 'password': password };
这是我的错误

authenticate: function () {
            // var username = this.getProperties('username');
            // var password = this.getProperties('password');

            const {username, password} = this.getProperties('username', 'password');

            this.get('session').authenticate('authenticator:oauth2', username, password).catch((reason) => {
                this.set('errorMessage', reason.error || reason);
            });
        }