I'm trying to get a token using rest controller and AuthorizationServerTokenServices.
I want to send my OAuth2Authentication through my body:
this is my request:
POST /external/oauth/token HTTP/1.1
Host: localhost:9000
Authorization: Basic Y2xpZW5012345678901234==
Content-Type: application/x-www-form-urlencoded
Cache-Control: no-cache
Postman-Token: ebec711e-dc8f-4abc-ab54cd-61ec1234567
username=x&password=x&grant_type=x&scope=read write
- username=x&password=x&grant_type=x&scope=read write is a raw and Text
and this is controller:
@RequestMapping(value = {"/external/oauth/token","/external/oauth/token"}, method=RequestMethod.POST ,consumes = {MediaType.APPLICATION_FORM_URLENCODED_VALUE,MediaType.ALL_VALUE},
produces = {MediaType.APPLICATION_ATOM_XML_VALUE, MediaType.APPLICATION_JSON_VALUE,MediaType.ALL_VALUE})
public OAuth2AccessToken getAccessToken( OAuth2Authentication temp) {
///not important
}
When im trying to run this endpoint im getting null on the passing object(=temp)
I'm attaching my http configure:
@Override
public void configure(HttpSecurity http) throws Exception {
http
.userDetailsService(userDetailsService)
.authorizeRequests()
.antMatchers(
"/**/users/**"
, "/**/groups/**"
)
.authenticated()
.and()
.authorizeRequests()
.anyRequest().permitAll();
}
}