我太沮丧了,我不明白为什么在页面刷新时ember-simple-auth不能持续...我将返回access_token,并遵循文档实现oauth2……
这是我的代码:
authenticators/oauth2.js:
import OAuth2PasswordGrant from 'ember-simple-auth/authenticators/oauth2-password-grant';
export default OAuth2PasswordGrant.extend({
serverTokenEndpoint: 'http://localhost:3000/users/compare'
});authorizers/oauth2.js:
import OAuth2Bearer from 'ember-simple-auth/authorizers/oauth2-bearer';
export default OAuth2Bearer.extend();适配器/application.js:
import DS from 'ember-data';
import DataAdapterMixin from 'ember-simple-auth/mixins/data-adapter-mixin';
const {
JSONAPIAdapter
} = DS;
export default JSONAPIAdapter.extend(DataAdapterMixin, {
authorizer: 'authorizer:oauth2',
host: 'http://localhost:3000'
});我将返回access_token和用户名。我可以看到经过身份验证的路由,但如果刷新页面,会话将丢失。
在我的认证对象中,我有:
access_token: "token"
username: "myUserName"在我的安全对象中,我有:
authenticator: "simple-auth-authenticator:jwt"
access_token "token"
username: "myUserName"我不明白为什么这个验证器..我正在使用它,但我已经删除了所有相关的东西。
在我的localStorage中,我有:
{"secure":{"authenticator":"simple-auth-authenticator:jwt","token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6Im1hcmNlbG9AcHViY3Jhd2xzcC5jb20iLCJpYXQiOjE0NDk1OTY5NDV9.fP11KL2as2mI7ocFojS-H3jUW60XgWCUskTNi4iy1XY","name":"Fatima Alves"},"authenticated":{"authenticator":"authenticator:oauth2","access_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6Im1hcmNlbG9AcHViY3Jhd2xzcC5jb20iLCJpYXQiOjE0NTAzMDU3MDN9.GKb5A15BBXxgcO9SDrGnxv0CQvkhXQCqvrK65MQ2ROc","name":"Fatima Alves"}}发布于 2015-12-17 15:19:13
您缺少安全数据中的某些属性,这些属性是OAuth2PasswordGrantAuthenticator正确还原所必需的。
https://stackoverflow.com/questions/34323648
复制相似问题