What I mean is that even though the code is the same, the server is executing two different paths through the code, depending on whether you’re on staging or not. The path being executed on staging includes your oauth library more than once, causing the error.
Typically, this kind of thing is caused by an error handler or some sort of other if-then check. If your staging auth flow redirects to production at the end, how are you getting back to staging in order to complete auth?