Integrate Alpaca API for paper & live trading in web application

Hello,

I am trying to integrate Alpaca API into my web application. I have registered OAuth app into my Alpaca account and developed Java backend API to call Alpaca API.
In my Java code I have added following parameters and called Alpaca
MultiValueMap<String, String> map = new LinkedMultiValueMap<>();
map.add(“grant_type”, “authorization_code”);
map.add(“code”, “UserCode received from Alpaca OAuth”);
map.add(“client_id”, “my client id”);
map.add(“client_secret”, “my client secret”);
HttpEntity<MultiValueMap<String, String>> request = new HttpEntity<>(map, headers);
ResponseEntity response = restTemplate.postForEntity(“https://api.alpaca.markets/oauth/token”, request, AlpacaAuth.class);

I am getting following error:
422 Unprocessable Entity: [{“code”:40010001,“message”:“invalid_grant”}]

Kindly help me.

Thanks.
Vrajesh Jayswal