How to customize Oauth2/token endpoint in Spring-authorization-server for Authorization Code grant type or any?
currently I have not configured any authorization server. so to get the token, its basically straight forward.
existing code sample
//Rest Controller
@RestController
@RequestMapping("api/v1")
public class TokenController{
@PostMapping("/token")
public TokenResponse getToken(@RequestBody TokenRequest tokenRequest){
return tokenService.getToken(tokenRequest);
}
}
@Data
@NoArgsConstructor
@AllArgsConstrucor
@Builder
public class TokenRequest {
String grantType;
String CustomerName;
String customerId;
}
As mentioned above, from the tokenRequest, I am getting the customerName, and sessionId and then I am searching for it in the database. once the record is found, I am adding it to the jwt user claim set.And the access token gets generated.
Now i decided to make use of spring's inbuilt Oauth2Authorization server as mentioned in spring doc
openid-configuration shows the token endpoint [oauth2/token] however this endpoint takes only the below in the requestBody
- grantType
- redirection_uri
- code // this is the authorization code which I get in the [oauth2/authorize](oauth2/authorize) call
My question is how can i add, customerName and customerId to this [oauth2/token](/oauth2/token) endpoint ?
are there any references that I can follow ?
in the latest spring boot I do not see @EnableAuthorizationServer