I am using following spring boot dependencies.
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.4.5</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency> </dependencies>
I configured Authorization header for the rest endpoint like below.
@RestController @Api(tags = "Welcome Controller", description = "Welcome API") public class HomeController { @ApiOperation(value = "Sent secret message", notes = "Sent secret message") @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Access Token", required = false, allowEmptyValue = false, paramType = "header", dataTypeClass = String.class, example = "Bearer access_token") }) @GetMapping("/secret-message") public Object tokenResponse() { Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal(); return principal; } }
But when I opened the swagger and try to execute the rest end point with Bearer token, this Authorizaiton header is not sent as part of the request. How can we resolve this?
References https://github.com/tiangolo/fastapi/issues/1037 https://github.com/tiangolo/fastapi/issues/612
https://stackoverflow.com/questions/67225923/authorization-header-is-not-sent-in-swagger-calls April 23, 2021 at 03:46PM
没有评论:
发表评论