# Integrate Alpaca API for paper & live trading in web application

**URL:** <https://forum.alpaca.markets/t/integrate-alpaca-api-for-paper-live-trading-in-web-application/3682>\
**Category:** Alpaca Integration Applications\
**Created:** [December 20, 2020, 1:51pm UTC](https://forum.alpaca.markets/t/integrate-alpaca-api-for-paper-live-trading-in-web-application/3682 "2020-12-20T13:51:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vrajesh\_Jayswal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/vrajesh_jayswal/32/1732_2.png) [@Vrajesh\_Jayswal](https://forum.alpaca.markets/u/Vrajesh_Jayswal)\
**Post date:** [December 20, 2020, 1:51pm UTC](https://forum.alpaca.markets/t/integrate-alpaca-api-for-paper-live-trading-in-web-application/3682/1 "2020-12-20T13:51:03Z")

</div>

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](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
