I finally found a solution that seems to work well.
Just some context, initially I was using my personal iCloud account as a sandbox account. It worked for a couple of days and then I started getting this same error. Eventually I found out that there is a "Sandbox" session on App Store Connect, where you can create sandbox accounts for the apps your are developing.
Go to App Store Connect -> Users and Access -> Sandbox.
Create a new Sandbox account from there and use this one on your device. Now everything is back to normal :)