401 error generating token in some rare cases

Whats the message you get with your 401?

You need to return the body/response as well as just the HTTP code.

The common issue here is that for some reason the code gets double used.