解决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);
                }
            }
posted @ 2020-07-28 14:05  百小僧  阅读(1746)  评论(1编辑  收藏  举报