Java 使用身份验证代码流的Swagger Oauth2使用了错误的回调url

Java 使用身份验证代码流的Swagger Oauth2使用了错误的回调url,java,Java,我有一个springboot应用程序,它使用oauth2公开安全RESTAPI。我正在开发swagger ui,以便在调用api时能够在标头中设置承载令牌。因此,我在swagger ui上添加了启用授权按钮的代码,但找不到指定回调url以验证用户身份的方法。当我点击授权按钮时,它会弹出一个弹出窗口,将我带到一个新选项卡,该选项卡有错误的回调url。我编辑了地址栏上的url,以查看流的其余部分是否正常工作。它向我展示了用户登录页面,但在我输入凭据后,它不会出现在任何地方。我希望它返回到带有auth

我有一个springboot应用程序,它使用oauth2公开安全RESTAPI。我正在开发swagger ui,以便在调用api时能够在标头中设置承载令牌。因此,我在swagger ui上添加了启用授权按钮的代码,但找不到指定回调url以验证用户身份的方法。当我点击授权按钮时,它会弹出一个弹出窗口,将我带到一个新选项卡,该选项卡有错误的回调url。我编辑了地址栏上的url,以查看流的其余部分是否正常工作。它向我展示了用户登录页面,但在我输入凭据后,它不会出现在任何地方。我希望它返回到带有auth令牌的swagger用户界面,auth令牌将被添加到每个api调用的头中。有人有这个流程来工作吗

    @Bean
public springfox.documentation.swagger.web.SecurityConfiguration security() {
    Map<String, Object> additionalQueryStringParams = new HashMap<>();
    return SecurityConfigurationBuilder.builder().scopeSeparator(" ")
            .clientId(clientId)
            .clientSecret(secret)
            .useBasicAuthenticationWithAccessCodeGrant(true).build();
}
private SecurityScheme securityScheme() {
    GrantType grantType = new AuthorizationCodeGrantBuilder()
            .tokenEndpoint(new TokenEndpoint(AUTH_SERVER + "/token", "id_token"))
            .tokenRequestEndpoint(
                    new TokenRequestEndpoint(AUTH_SERVER + "/authorize", clientId, secret))
            .build();

    SecurityScheme oauth = new OAuthBuilder().name("spring_oauth")
            .grantTypes(Arrays.asList(grantType))
            .scopes(Arrays.asList(scopes()))
            .build();
    return oauth;
}
private AuthorizationScope[] scopes() {
    AuthorizationScope[] scopes = {
            new AuthorizationScope("openid", "")};
    return scopes;
}
private SecurityContext securityContext() {
    return SecurityContext.builder()
            .securityReferences(
                    Arrays.asList(new SecurityReference("spring_oauth", scopes())))
            .forPaths(PathSelectors.any())
            .build();
}
@Bean
public springfox.documentation.swagger.web.SecurityConfiguration安全性(){
Map additionalQueryStringParams=new HashMap();
返回SecurityConfiguration builder.builder().scopeSeparator(“”)
.clientId(clientId)
.clientSecret(秘密)
.useBasicAuthenticationWithAccessCodeGrant(true).build();
}
私人证券计划证券计划(){
GrantType GrantType=新授权代码GrantBuilder()
.tokenEndpoint(新的tokenEndpoint(身份验证服务器+“/token”,“id\u token”))
.tokenRequestEndpoint(
新的TokenRequestEndpoint(AUTH_SERVER+“/authorize”,clientId,secret))
.build();
SecurityScheme oauth=新的OAuthBuilder().name(“spring_oauth”)
.grantType(数组.asList(grantType))
.scopes(Arrays.asList(scopes()))
.build();
返回oauth;
}
私有授权作用域[]作用域(){
授权范围[]范围={
新的授权范围(“openid”,即“)};
返回范围;
}
私有SecurityContext SecurityContext(){
返回SecurityContext.builder()
.证券参考(
asList(新的SecurityReference(“spring_oauth”,scopes()))
.forpath(路径选择器.any())
.build();
}

请添加您的代码。