It is not difficult to retrieve the 6-digit code or passkey on the Xbox app. You can easily reset the passkey with your existing Microsoft account.
First, you need to enter the wrong passkey three times when prompted. And then, you need to enter the Microsoft password when prompted to reset the passkey with a new one.