Bitbucket Cloud access tokens last about two hours. The import page only needs them while you are on that page. Refreshing the token in the session looked like the right fix, until a reviewer pointed out that the refresh itself was the problem.
This is the story of gitlab-org/gitlab!272089 . I'll cover the issue that asked us to persist a rotated refresh token, the first version that tried to do that, the review that replaced it with a re-authorize flow, and the later comments that kept import polling from kicking the user out mid-import.
The issue: a refresh token that was already dead
The issue was gitlab-org/gitlab#640895 , opened by Jasmin Taj Shaik. Import::BitbucketController could refresh an expired Bitbucket OAuth token, but it never wrote the new credentials back into the session.
Bitbucket Cloud rotates refresh tokens. The previous refresh token is invalid after the first refresh.…