carnellj / spmia-chapter7

Source code for chapter 7 of Spring Microservices in Action
46 stars 133 forks source link

Null Pointer Exception when calling GET request /auth/user #9

Open seymurasadov opened 6 years ago

seymurasadov commented 6 years ago

Spring Microservices In Action 7.2 ends

@RequestMapping(value = { "/user" }, produces = "application/json")
    public Map<String, Object> user(OAuth2Authentication user) {
        Map<String, Object> userInfo = new HashMap<>();
        userInfo.put("user", user.getUserAuthentication().getPrincipal());
        userInfo.put("authorities", AuthorityUtils.authorityListToSet(user.getUserAuthentication().getAuthorities()));
        return userInfo;
    }

OAuth2Authentication user is null