OAuth2 Spring boot缺少必要的 "用户名"。

问题描述 投票:0回答:1

我试图使用Spring Boot OAuth通过Zoom进行授权 (https:/marketplace.zoom.usdocsguidesauthoauth。)

我正试图打开页面( /zoom endpoint),我的应用程序将我重定向到zoom。在这里我输入zoom账户,Spring将我重定向到错误页面。

[missing_user_name_attribute] Missing required "user name" attribute name in UserInfoEndpoint for Client Registration: zoom

不知道该如何处理它。这是我的代码

配置

@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests().antMatchers("/", "/login**", "/error**").permitAll()
                .anyRequest().authenticated()
                .and().logout().logoutUrl("/logout").logoutSuccessUrl("/")
                .and().oauth2Login();
    }

    @Bean
    public ClientRegistrationRepository clientRegistrationRepository() {
        List<ClientRegistration> registrations = new ArrayList<>();
        registrations.add(zoomClientRegistration());
        return new InMemoryClientRegistrationRepository(registrations);
    }

    private ClientRegistration zoomClientRegistration() {
        return ClientRegistration.withRegistrationId("zoom")
                .clientId(/**myClientId**/)
                .clientSecret(/**{myClientSecret}**/)
                .clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
                .authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
                .redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}")
                .authorizationUri("https://zoom.us/oauth/authorize")
                .tokenUri("https://zoom.us/oauth/token")
                .userInfoUri("https://api.zoom.us/v2/user")
                .clientName("Zoom").build();
    }
}

在Zoom应用中,我配置了

OAuth的重定向网址。http://{my_host_name}/login/oauth2/code/zoom

白名单URL。http://{my_host_name}/zoom

我的应用程序也有端点在 /zoom

java spring spring-boot oauth zoom
1个回答
0
投票

你必须在客户端注册处添加userNameAttributeName,并设置为正确的用户名属性,它可以是openId的 "sub",也可以是 "email"、"id "等不同的属性,请检查以下内容 https:/api.zoom.usv2用户。 响应,以查找哪些属性匹配。

祝贺

© www.soinside.com 2019 - 2024. All rights reserved.