I am trying to implement Oauth2 in my existing application.Initially I have added spring security and then tried to add oauth2, After adding configuration I am able to gener
I suspect the problem might be the way you save/load roles. In spring security there is a default prefix for roles: ROLE_. So in your DB (storage) you need to save them as ROLE_FOO for example and then you can use hasRole('FOO')
I found the same problem here, and my answer seemed to solve the problem: https://stackoverflow.com/a/43568599/4473822
The person that got the issue also had 403 - Forbidden and saving the roles correctly in the DB solved the problem.
You can also change the default prefix but I would not recommend it unless you want to mess with spring a bit.