Spring boot 我使用的是spring boot 1.4.2,我在oauth2实现方面遇到了问题,我如何获得google或facebook注册ID
我使用的是spring boot 1.4.2,而oauth2实现有问题, 如何获取谷歌或facebook注册IDSpring boot 我使用的是spring boot 1.4.2,我在oauth2实现方面遇到了问题,我如何获得google或facebook注册ID,spring-boot,spring-security,oauth-2.0,Spring Boot,Spring Security,Oauth 2.0,我使用的是spring boot 1.4.2,而oauth2实现有问题, 如何获取谷歌或facebook注册ID @GetMapping("/google") //todo add oauth2 authentication! public String getGoogle(Principal principal) { String password = UUID.randomUUID().toString(); String encode = passwor
@GetMapping("/google") //todo add oauth2 authentication!
public String getGoogle(Principal principal) {
String password = UUID.randomUUID().toString();
String encode = passwordEncoder.encode(password);
UserDetailsModel userDetails = null;
Collection<? extends GrantedAuthority> authorities = null;
if (principal != null) {
OAuth2Authentication oAuth2Authentication = (OAuth2Authentication) principal;
Authentication authentication = oAuth2Authentication.getUserAuthentication();
Map<String, Object> map = (Map<String, Object>) authentication.getDetails();
authorities = authentication.getAuthorities();
userDetails = userDetailsRepository.findUserDetailsModelByMailId((String) map.get("email"));
if (userDetails == null) {
userDetails = new UserDetailsModel();
userDetails.setFirstname((String) map.get("given_name"));
userDetails.setLastname((String) map.get("family_name"));
userDetails.setEmail((String) map.get("email"));
}
}
@GetMapping(“/google”)//todo添加oauth2身份验证!
公共字符串getGoogle(主体){
字符串密码=UUID.randomuid().toString();
字符串encode=passwordEncoder.encode(密码);
UserDetailsModel userDetails=null;
收集