我的Spring Boot应用程序引发异常,因为email请求参数为空字符串,Facebook不发送用户的电子邮件地址,因为用户未授予权限。 解决此问题的最佳实践/方法是什么? 我目前的代码:
@PostMapping("/user/facebook")
public ResponseEntity<?> RegOrAuthUserWithFacebookToken(@Valid @RequestBody FacebookLoginRequest fbReq, Locale locale) {
String email = userFacade.createOrUpdateFacebookUser(fbReq, locale);
Authentication authentication = authenticationManager
.authenticate(new FacebookAuthenticationToken(email, fbReq.getAccessToken()));
SecurityContextHolder.getContext().setAuthentication(authentication);
return ResponseEntity.ok()
.body(new ApiResponse(new JwtAuthenticationResponse(tokenProvider.generateToken(authentication), UserRole.ROLE_USER.name())));
}