Spring doc openapi oauth2 resource server not working

297 views Asked by At

Although I have successfully authorize but when I get api 401 is there any way to fix it.

Authorize swagger

Execute api swageer

Swagger config application.yml

springdoc:
  version: 'v1.0'
  swagger-ui:
    oauth:
      use-basic-authentication-with-access-code-grant: true
      use-pkce-with-authorization-code-grant: true
      client-id: USER_CLIENT_APP
      client-secret: password
  oAuthFlow:
    authorizationUrl: ${OAUTH2_SERVER:http://localhost:8080}/oauth/authorize
    tokenUrl: ${OAUTH2_SERVER:http://localhost:8080}/oauth/token

OpenApiConfig.class

@OpenAPIDefinition(info = @Info(title = "User",
        description = "description", version = "v1"))
@SecurityScheme(name = "security_auth", type = SecuritySchemeType.OAUTH2,
        flows = @OAuthFlows(password = @OAuthFlow(
                authorizationUrl = "${springdoc.oAuthFlow.authorizationUrl}",
                tokenUrl = "${springdoc.oAuthFlow.tokenUrl}",
                scopes = {
                        @OAuthScope(name = "trust", description = "trust scope"),
                        @OAuthScope(name = "read", description = "read scope"),
                        @OAuthScope(name = "write", description = "write scope")
                })))
public class OpenApiConfig {}

get token

post-man get /oauth/token

I want to access oauth2 in springdoc openapi.

0

There are 0 answers