Forum Discussion

NadChel's avatar
NadChel
New Member
4 months ago

Enabling "Authorize" button

How do I enable the "Authorize" button in Swagger UI? I got it all set up, but if the endpoints require authentication, it's not going to work straight from the UI. I need to be able to pass tokens as `Authorization` header values

Do I need to pass some yml property? I have a Java app

Should I write something here?

```java

@SpringBootApplication
@OpenAPIDefinition(info = info(version = "1.0", title = "Hello World API"), security = @SecurityRequirement(name = "/* here */"))
public class HelloworldMreApplication {

public static void main(String[] args) {
SpringApplication.run(HelloworldMreApplication.class, args);
}

}

```

I tried this:

```java

@RestController
@RequestMapping("/auth")
@Tag(name = "Message Controller")
@SecurityScheme(type = SecuritySchemeType.HTTP, name = "basicAuth")
public class MessageController {


@GetMapping("/hello-world")

// ...

```

I got the button, but it's not useful. Once I click on it, I get a popup that says "Available authorizations" and that's it

A more verbose variation produced the same result
```java

@SecurityScheme(type = SecuritySchemeType.HTTP, name = "basicAuth",
description = "authorization with JWT token", scheme = "token",
bearerFormat = "bearer")

```

No RepliesBe the first to reply