spring-attic / spring-security-oauth

Support for adding OAuth1(a) and OAuth2 features (consumer and provider) for Spring web applications.
http://github.com/spring-projects/spring-security-oauth
Apache License 2.0
4.7k stars 4.04k forks source link

refresh token #1679

Open 99bird opened 5 years ago

99bird commented 5 years ago

I use username password to get access_token and refresh_token ,then ,I use the refresh_token to refresh token . response is server error. All was default config java.lang.IllegalStateException: UserDetailsService is required. image image

aaabidunique commented 5 years ago

Can you tell me what exception you are getting in your application after hitting refresh token url?

99bird commented 5 years ago

the exception is "java.lang.IllegalStateException: UserDetailsService is required".

aaabidunique commented 5 years ago

@99bird Well thats what I thought. Just define a custom service extending UserDetailService and that will fix the issue. FYI, userDetailService is required to validate whether the user is still active and was not blocked for some reason.

99bird commented 5 years ago

I'm sure the userDetails has exisit. It'work well when I get an access_token

aaabidunique commented 5 years ago

@99bird userDetailService is not responsible when you are generating access_token instead authenticationProvider does that. userDetailService comes into picture when you are trying to refresh token. FYI, make sure you created the bean of userDetailService properly i.e @service, @Bean or any other way. One more thing, can you update the title and description properly so that its easier for anyone in the future and label to question also.

christian1607 commented 5 years ago

I have the same problem but in my case i can get the UserDetails but after that and I don't know why spring calls my loadUserByUsername() method. this is the mehod that raise a UsernameNotFoundException

aaabidunique commented 5 years ago

@christian1607 As I already mentioned userDetailService is responsible for validating whether user is still active or not. Please check my previous comment.

christian1607 commented 5 years ago

@aaabidunique you're right.