首页 文章

Ember Simple Auth(带有令牌插件)不会添加具有令牌的Authorization标头

提问于
浏览
1

我有一个简单的工作应用程序与Ember CLI 0.1.12 . 我使用Ember Simple Auth插件和令牌验证器和授权器 . https://github.com/jpadilla/ember-cli-simple-auth-token

首先,我无法进行身份验证,因为我不知道服务器应该返回什么 . 经过大量的谷歌搜索,我能够弄清楚服务器应该返回这样的东西:

{“access_token”:“ToKeN123hEre”}

现在我能够进行身份验证和会话工作 . 但是当我进行其他调用时,Authorization标头不会出现在请求标头中,因此服务器无法知道该标记 .

This is what I have tried so far:

设置我的environment.js文件:

ENV['simple-auth'] = {
  crossOriginWhitelist: ['*'],
  authorizer: 'simple-auth-authorizer:token',
  routeAfterAuthentication: '/profile'
};

ENV['simple-auth-token'] = {
  serverTokenEndpoint: '/api0/auth',
  identificationField: 'username',
  passwordField: 'password',
  tokenPropertyName: 'token',
  authorizationPrefix: 'Bearer ',
  authorizationHeaderName: 'Authorization',
  headers: {}
};

使我的服务器使用CORS并允许来自任何Origin的Authentication头和请求 .

1 回答

  • 1

    我最后改为“access_token”只是为了“令牌”,现在它可以正常工作 .

相关问题