title: Change Authorities/Roles of Authenticated User from SSO in Spring OAuth2 Client
body: <p>I am trying to authenticate a user from facebook and store it's username and provide custom permission to subset of users who will be admin for my application. My question is, How do I provide custom roles like "Admin" to the authenticated and authorize it in Oauth2Client.</p>
  
  <pre><code>@Configuration
  class WebSecurityConfiguration extends GlobalAuthenticationConfigurerAdapter {
  
  @Autowired
  UserRepository userRepository;
  
  @Override
  public void init(AuthenticationManagerBuilder auth) throws Exception {
      auth.userDetailsService(userDetailsService());
  
  }
  
  @Bean
  UserDetailsService userDetailsService() {
      return new UserDetailsService() {
          @Override
          public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
              User account = userRepository.findOne(username);
              if (account != null) {
                  List&lt;String&gt; rolesList = userRepository.getRoles(username);
                  String[] roles = new String[rolesList.size()];
  
  
                   // userRepository.findRoles List&lt;String&gt; roles =
                   //account.getUserroles().;
                   User user = new User(account.getUserssoid(), account.getSecretKey(), true, true, true, true,
                          AuthorityUtils.createAuthorityList(rolesList.toArray(roles)));
  
                  return user;
              } else {
                  throw new UsernameNotFoundException("could not find the user '" + username + "'");
              }
          }
      };
  }
  }
  </code></pre>
  
  <p>I want to do similar thing using OAuth2 Client.</p>
  
  <p>Thanks</p>