Fix some bugs in authentication to Forgejo servers.
Review Request #15131 — Created June 23, 2026 and submitted — Latest diff uploaded
The Forgejo authentication path had a few issues, which this change
fixes:
get_http_credentialswas returning aheaderkey as per the base
HostingServiceClientdocstring, but this should have beenheaders.
I've fixed both the bug in the Forgejo client as well as the incorrect
docstring.- Some API errors don't include the
urlfield, which was marked as
required in the Pydantic schema. - Re-authentication ("Edit Credentials") was broken because it would
still try to use the saved API key, resulting in an error about not
having the "user:write" scope.
Due to the fix for the re-authentication issue, I discovered that the
HostingServiceTestCase.create_hosting_account method was aliasing
default_account_data instead of copying it, which allowed tests to
interfere with each other.
- Authenticated to a new Forgejo server with both 2FA required and not.
- Re-authenticated and saw that it correctly issued a new API token
instead of getting a scope error. - Ran unit tests.