我正在尝试使用Spring Boot OAuth通过Zoom(https://marketplace.zoom.us/docs/guides/auth/oauth)对我的应用进行授权
我正在尝试打开页面(/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 Application中
OAuth的重定向URL:http://{my_host_name}/login/oauth2/code/zoom
白名单提示:http://{my_host_name}/zoom
我的应用还具有/zoom
的端点
答案 0 :(得分:1)
您必须在ClientRegistration处添加userNameAttributeName并设置为正确的用户名属性,对于openId,它可以是“ sub”,但是对于“ email”,“ id”,它也可以是其他名称,请检查https://api.zoom.us/v2/user响应以查找哪个属性匹配。
致谢