解决Swagger刷新后不能保持登录问题
https://github.com/domaindrivendev/Swashbuckle.AspNetCore/issues/785
https://www.it1352.com/1700234.html
https://www.e-learn.cn/topic/3416881
https://mac-blog.org.ua/dotnet-core-swashbuckle-3-bearer-auth/
var configObject = JSON.parse('%(ConfigObject)');
configObject.responseInterceptor = function (rep) {
if (rep.ok && rep.url.indexOf('/api/Authorization/SignIn') > -1) {
window.sessionStorage.setItem("HoaSwaggerToken", rep.obj.accessToken);
}
}
configObject.onComplete = function () {
var token = window.sessionStorage.getItem("HoaSwaggerToken");
if (token) {
ui.preauthorizeApiKey("Bearer", token);
}
}
如果您觉得本文对你有用,不妨帮忙点个赞,或者在评论里给我一句赞美,小小成就都是今后继续为大家编写优质文章的动力,百小僧拜谢!
欢迎您持续关注我的博客:)
版权所有,欢迎保留原文链接进行转载:)