Problem Statement
Some of our users are encountering an invalid authorization code error after completing authentication in a NextJS application using the nextjs-auth0 SDK.
Troubleshooting
- Check the dashboard logs to determine whether a duplicate exchange is being executed.
- If a duplicate exchange is identified, investigate whether there is a double redirect to the callback in the browser.
- If there is no double redirect, review the logic concerning the location of the code exchange.
Cause
- This issue usually arises due to a double redirect, which leads to the code exchange being triggered twice.
Solution
Ensure that there is no occurrence of a double redirect (refer to troubleshooting steps). In case no redirect is present, verify that there is no redundant flow and that the callback is appropriately associated with the original request.