API OAuth 2.0: Request failed with status code 400
API OAuth 2.0: Request failed with status code 400
I'm using the Zoho Mail API trying to follow these
instructions
for OAuth2.0.
1. I called the Authorization URI GET request in the browser address bar:
https://accounts.zoho.com/oauth/v2/auth?scope=ZohoMail.folders.READ&client_id=1000.23UUJK43IAZY4NK9BOSL47RVJYUY6T&response_type=code&redirect_uri=http://localhost:4000/zoho_callback&state=87654677676321
2. Then in my backend in url callback (
http://localhost:4000/zoho_callback
)
I construct this url, adding in the state and code obtained from the request made by zoho to this callback.
const url = `
https://accounts.zoho.com/oauth/v2/token?state=${
state
}&scope=ZohoMail.folders.READ&code=${
code
}&grant_type=authorization_code&client_id=1000.23UUJK43IAZY4NK9BOSL47RVJYUY6T&client_secret=<
I put my client secret here
>&redirect_uri=http://localhost:4000/zoho_callback
`;
3. And I then make a post request from within my callback endpoint.
const resp = await axios.post(url);
4. But this gives me an error:
Request failed with status code 400
But I can't tell why I'm getting a 400 error. It's not giving me anymore info.