Is the one-time code used up when the exchange fails? Yes. The first attempt uses the code up, whether it succeeds or not. Start again from the app. More: Connected apps, The code and the tokens