[英]Why does Ember-Simple-Auth support refresh tokens? (JS + OAuth 2.0)
[英]Ember-simple-auth does not persist refresh's
我很沮丧,我无法弄清楚为什么当页面刷新时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"}}
您缺少安全数据中的某些属性, OAuth2PasswordGrantAuthenticator
才能正确还原这些属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.