无效令牌不包含资源id(oauth2\u应用程序)

ycggw6v2  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(197)

下面是我的配置 oauth2 ,当尝试转到一个页面时,我被重定向到执行身份验证。启动身份验证后,我收到消息:
无效令牌不包含资源id(oauth2\u应用程序)

@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    private String[] swaggerPathPatterns() {
        return new String[]{
                "/v2/api-docs",
                "/configuration/ui",
                "/swagger-resources/**",
                "/configuration/security",
                "/swagger-ui.html",
                "/webjars/**"
        };
    }

    @Override
    protected void configure(HttpSecurity http) throws Exception {

        http
                .authorizeRequests(a -> a
                        .antMatchers("/status/**", "/actuator/**").hasRole("USER")
                        .antMatchers(swaggerPathPatterns()).hasRole("USER")
                        .anyRequest().authenticated()
                )
                .oauth2Login();
        // @formatter:on
    }
}

应用程序属性:

spring.security.oauth2.client.registration.bv-auth.authorization-grant-type=......
spring.security.oauth2.client.registration.bv-auth.client-id=.....
spring.security.oauth2.client.registration.bv-auth.client-name=.....
spring.security.oauth2.client.registration.bv-auth.client-secret=.....
spring.security.oauth2.client.registration.bv-auth.redirect-uri=.....
spring.security.oauth2.client.registration.bv-auth.scope=.....

spring.security.oauth2.client.provider.bv-auth.authorization-uri=.....
spring.security.oauth2.client.provider.bv-auth.jwk-set-uri=.....
spring.security.oauth2.client.provider.bv-auth.token-uri=.....
spring.security.oauth2.client.provider.bv-auth.user-info-uri=.....
spring.security.oauth2.client.provider.bv-auth.user-name-attribute=.....

spring.security.oauth2.resourceserver.jwt.jwk-set-uri=.....

任何帮助都将不胜感激。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题