java - Spring security OAUTH - Invalid credentials - Stack Overflow

Struggling with this error, while I trying loginvia OAUTH GOOGLE.My securityfilterchian@Beanpublic Se

Struggling with this error, while I trying login via OAUTH GOOGLE.

My securityfilterchian

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        //http.cors(cors -> cors.configurationSource(corsConfigurationSource()));
        http.cors(cors -> cors.disable());
        http.csrf(csrf ->csrf.ignoringRequestMatchers("/oauth/*", "/auth/user"));
        http.authorizeHttpRequests(request -> request.requestMatchers("/oauth/*","/auth/user").permitAll().anyRequest().authenticated());
        http.oauth2Login(login -> login.successHandler(((request, response, authentication) -> response.sendRedirect("/auth/user"))));




        return http.build();
    }

in application.properties

spring.security.oauth2.client.registration.google.client-id= my client id
spring.security.oauth2.client.registration.google.client-secret= my client secret 

Is there something else what I have to configurate ?

EDIT (SOLVED)

reason of 'Invalid credentials' was my sessions, which was 'null'. Reason of this null was automatically set up 'sameSite' cookies by this @Bean

@Bean
public CookieSameSiteSupplier applicationCookieSameSiteSupplier() {
    return CookieSameSiteSupplier.ofStrict();
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744071191a4553570.html

相关推荐

  • java - Spring security OAUTH - Invalid credentials - Stack Overflow

    Struggling with this error, while I trying loginvia OAUTH GOOGLE.My securityfilterchian@Beanpublic Se

    9天前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信