Cannot send Authorization Bearer Token using Springfox(无法使用 Springfox 发送授权承载令牌)
问题描述
我无法理解为什么没有使用 Springfox 2.5.0 在我的 api 中发送授权:承载 __".我有以下配置:
发送的卷曲是:
似乎我无法在 springfox (2.5.0) 中发送Authorization: Bearer Token",这可能吗?这是一个已知问题吗?
类似问题:
我希望有一种更自动化的方式.但就目前而言,似乎文本框中的内容简单获取已粘贴到给定标题条目的值部分.我想前缀 Bearer 没有被自动注入的原因是因为 Swagger 会对它的用户使用哪种身份验证非常固执!
REST 端点方法:
登录前的curl命令:
回复:
登录后的curl命令:
回复:
注意:我的代码是用 Groovy 编写的,如果您使用标准 Java,我相信您可以翻译.
I'm having trouble understanding why "Authorization: Bearer __" is not being sent in my api using Springfox 2.5.0. I have the following configuration:
And the curl being sent is:
It seems I am unable to send "Authorization: Bearer Token" in springfox (2.5.0), is this possible?, is it a known problem?
Similar issue: https://github.com/springfox/springfox/issues/1812
PS: OpenAPI 3.0 allows the "bearer" format, example: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#jwt-bearer-sample
Thanks.
A simple workaround is to type Bearer
than paste the token after it. You will end up with a text box that contains:
I wish there was a more automated way. But for now, it appears as though what goes in the text box simple get's pasted into the value section of a given header entry. I suppose the reason the prefix Bearer
does not get injected automatically is because then Swagger would be quite opinionated about which sort of authentication its users used!
The REST endpoint method:
The curl
command before logging in:
Response:
The curl
command after logging in:
Response:
Note: My code is in Groovy, I am sure you can translate if you are using standard Java.
这篇关于无法使用 Springfox 发送授权承载令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!