Problems connecting to Gitlab using PKCE
Hello everyone!
I'm working on a project with Decap CMS, which is connected to Gitlab, using the PKCE configuration to authenticate the user.
However, Decap is working intermittently. As you can see in the screenshot below, the user receives some error messages, especially during authentication.
The "token" and "user" routes are the most problematic, but other routes also behave intermittently.
The user is able to connect and use the CMS after several attempts. After these initial errors, the CMS remains stable for quite some time.
Have you ever seen a situation like this? If so, what was the solution?
Decap CMS Version: 3.8.3
Note: We've been using Decap CMS since 2024, and we started noticing this issue three weeks ago. We updated the project to the latest version, but the errors persist.
I traced the screenshots against the current backend. The failing /user response uses GitLab's standard REST body, {"message":"401 Unauthorized"}. The refresh handler added in #7854 only recognized the OAuth {"error":"invalid_token"} form, so this response did not trigger a refresh.
I added the exact response as a regression case in #7932, including the initial /user request during login. The change keeps support for the existing OAuth response and refreshes only once before returning the retry result.
This does not cover an intermittent failure from /oauth/token itself. If you can still reproduce that part, could you share whether this is GitLab.com or self-managed, the GitLab version if self-managed, and the status plus JSON body from /oauth/token with the code and tokens redacted? That would separate the token-exchange failure from the follow-up API authentication failure.
Decap now refreshes expired GitLab PKCE tokens (#7854, decap-cms 3.14.1), including GitLab's 401 on /user (#7932, decap-cms 3.16.1). Thanks for reporting, @brunocesarbulnes, and feel free to open a new issue if it still happens.