How can I convert the following curl request into HTTP post request in angular 7?
curl --request POST \
--url https://api.typeform.com/oauth/token \
--data-urlencode 'grant_type=authorization_code' \
--data-urlencode 'code={temporary_authorization_code}' \
--data-urlencode 'client_id={your_client_id}' \
--data-urlencode 'client_secret={your_client_secret}' \
--data-urlencode 'redirect_uri=https://results-example.herokuapp.com/callback'
I tried the approach below but it doesn't work
this.httpClient.post(environment.typeForm.base_url + 'token', JSON.stringify({
'grant_type' : 'authorization_code',
'code': `${authCode}`,
'client_id':`${*******}`,
'client_secret':`${*******}` ,
'redirect_uri':`${*******}`,
}));
The grant_type shoud be 'authroization_code' as specified int the typeform documentation.
This is the error I get
{"headers":{"normalizedNames":{},"lazyUpdate":null},"status":500,"statusText":"Internal Server Error","url":"https://api.typeform.com/oauth/token","ok":false,"name":"HttpErrorResponse","message":"Http failure response for https://api.typeform.com/oauth/token: 500 Internal Server Error","error":{"code":"internal_server_error","description":"Internal server error"}}
You can find the documentation of the API I'm trying to use here