java - Spring Boot Oauth2 Retrieving access token There is no client authentication. Try adding an appropriate authentication filter -
here's application.java
@springbootapplication @restcontroller @enableresourceserver @enableauthorizationserver public class application { @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; } public static void main(string[] args) { springapplication.run(application.class, args); } }
websecurityconfigurer.java
@configuration public class websecurityconfigurer extends websecurityconfigureradapter { @override @bean public authenticationmanager authenticationmanagerbean() throws exception { return super.authenticationmanagerbean(); } @override protected void configure(httpsecurity http) throws exception { http.csrf().disable(); } @override @bean public userdetailsservice userdetailsservicebean() throws exception { return super.userdetailsservicebean(); } @override protected void configure(authenticationmanagerbuilder auth) throws exception { auth .inmemoryauthentication() .withuser("john.carnell").password("password1").roles("user") .and() .withuser("william.woodward").password("password2").roles("user", "admin"); } }
my oauth2config
@configuration public class oauth2config extends authorizationserverconfigureradapter { @autowired private authenticationmanager authenticationmanager; @autowired private userdetailsservice userdetailsservice; @override public void configure(clientdetailsserviceconfigurer clients) throws exception { clients.inmemory() .withclient("eagleeye") .secret("thisissecret") .authorizedgranttypes("refresh_token", "password", "client_credentials") .scopes("webclient", "mobileclient"); } @override public void configure(authorizationserverendpointsconfigurer endpoints) throws exception { endpoints .authenticationmanager(authenticationmanager) .userdetailsservice(userdetailsservice); } }
i trying retrieve access token though postman however, error keeps showing up
{ "error": "unauthorized", "error_description": "there no client authentication. try adding appropriate authentication filter." }
these values i'm passing in through postman
what missing on config?
Comments
Post a Comment