I am trying to exchange an OAuth response code to get an access token and am getting the following error.
[invalid_client] client_id, redirect_uri and client_secret do not match existing setup
I am using the same client_id, redirect_uri and client_secret that I used in the in my initial request to Tradovate and am at a loss for what else I can try so any help is appreciated. I am following along the example shown here GitHub - tradovate/example-api-oauth
Here is my code.
// After coming back from a successful OAuth call to
const authUrl =
"https://trader.tradovate.com/oauth" +
`?response_type=code` +
`&client_id=${encodeURIComponent(CLIENT_ID)}` +
`&redirect_uri=${encodeURIComponent(REDIRECT_URI)}`;
const credentials = {
grant_type: "authorization_code",
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
redirect_uri: REDIRECT_URI,
code: req.query.code // This is coming back from a successful OAuth callback,
};
const response = await fetch("https://live-api-d.tradovate.com/auth/oauthtoken", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(credentials),
});
// await response.json() ->
// {
// error: 'invalid_client',
// error_description: 'client_id, redirect_uri and client_secret do not match existing setup'
// }