I encounter an error while integrating Notion into my web app; the access token returns a ‘code already used’ message. Below is my updated backend snippet:
I encountered a similar obstacle while integrating Notion into an application. The error resulted from the repeated use of the authorization code because the endpoint was triggering more than once. In my case, ensuring that the token exchange request was sent only once resolved the issue. I recognized the problem by adding detailed logging to track the request flow, revealing that the front-end inadvertently fired duplicate device authentication calls. A single-call approach, along with proper state management on the client side, proved effective, eliminating the error.
I experienced a similar recurring issue where my Notion integration kept failing because of duplicate token exchanges. The root cause lay in the asynchronous handling of requests, which inadvertently sent multiple token requests. In my case, establishing strict control flow with proper state verification ensured that the token exchange process was executed only once per authorization attempt. Logging the complete request flow helped to pinpoint the issue, and eventually, adding appropriate middleware to block duplicate calls resolved the error completely.
hey, i had similar issue - turned out its a double-request problem. fixed it by ensuring a single token call on server side. prob a race cond mess. check you client too, might be triggering twice. hope it helps