Error updating user preferences. Credentials not provided?

So,

I am still working through enabling badging.

Right now Im getting the error mentioned when I update user preferences after earning a badge.

I can’t change the profile picture, bio, similar for a long period.

I understand this may have to do with JWT.

Cant upload images as a new user

Im not sure how to get out of this error loop, obtain a new JWT token each time I earn a badge somehow?, as no error is being logged on lms or apache.

Thanks for reading this far

Looking at the logs I can get as far as requesting a user’s badge assertions then I am logged out.

Here is a gist showing what I can see https://gist.github.com/vicnete/143e8fab73137f37b6aadebea37dd35e

After a while it works and both of the requests include the username.

I am trying to figure out:

What may be causing this?
Why is it fixed after about 8 minutes?(some sort of user cache that logs me out when it is inconsistent is my best guess at the moment).

I have an idea of a fix for my situation, there is a solution manually and we could replicate what that solution is calling every time we issue a badge, but we need to get rid of the 8 minute/similar time cache.

Asking our users to wait around for 10 minutes before accessing their profile after earning a badge seems less than ideal.