I’m working on setting up OAuth authentication with Notion’s public integration API. Everything seems configured correctly but I keep hitting a wall with this redirect URI error.
My HTML page:
<!DOCTYPE html>
<html>
<head>
<title>Notion Integration</title>
</head>
<body>
<a href="https://api.notion.com/v1/oauth/authorize?client_id=b8e20155-957d-534e-ad77-e7cf8949dd64&redirect_uri=https%3A%2F%2Fmy-app-backend.herokuapp.com%2Fcallback%2Fnotion%2Fauth&response_type=code">
Connect with Notion
</a>
</body>
</html>
Backend route setup:
app.get("/callback/notion/auth/:code/:state", (req, res) => {
const authCode = req.params.code;
const stateParam = req.params.state;
console.log(authCode);
res.json({
"status": "callback received",
"code": authCode,
"state": stateParam
});
axios.post('https://api.notion.com/v1/oauth/token', {
grant_type: "authorization_code",
code: authCode,
redirect_uri: 'https://my-app-backend.herokuapp.com/callback/notion/auth/'
}).then((result) => {
console.log(result)
}).catch((error) => {
console.log(`request failed:`, error);
})
});
In my integration settings I set the redirect URI to https://my-app-backend.herokuapp.com/. The callback route never gets hit according to my server logs so I think there’s a mismatch somewhere in how I’m formatting these URLs. What am I missing here?