I am creating a notion API integration with OAuth authentication. I keep getting an invalid_client error when the user clicks allow access button and OAuth follow hits my callback URL. Also, auth_token is created in base64 format via client_id:client_secret which is provided in the integration console. Code is returned as query param when the OAuth process hits my callback URL.
What am I missing?
const code = req.query.code;
const auth_token = Buffer.from(
"my_oauth_client_id:my_oauth_client_secret" // provided in integration panel
).toString("base64");
await axios
.post(
"https://api.notion.com/v1/oauth/token", {
code,
grant_type: "authorization_code",
redirect_uri: "https://notion-fastlane-web-2hfaoof9v-oak93.vercel.app/api/notion/oauth/callback",
}, {
headers: {
"Content-Type": "application/json",
Authorization: `Basic ${auth_token}`,
},
}
)
.then(() => res.status(200).send("OK"))
.catch((error) => {
res.status(error.response.status).send(error.response.data);
});
};