fix provider_url to resolve local setup issue

While setting up the repo locally I got an error while trying to Login through Wikimedia Commons I forgot to push a patch at that time, covering it now

Error:

Screen_Shot_2025-02-12_at_10.31.58_PM

AuthException at /oauth/login/mediawiki/ Error: An error occurred in the OAuth protocol: Invalid consumer

Full Traceback:

Internal Server Error: /oauth/login/mediawiki/
Traceback (most recent call last):
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/social_django/utils.py", line 63, in wrapper
    return func(request, backend, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/social_django/utils.py", line 49, in wrapper
    return func(request, backend, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/social_django/views.py", line 23, in auth
    return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/social_core/actions.py", line 34, in do_auth
    return backend.start()
           ^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/social_core/backends/base.py", line 34, in start
    return self.strategy.redirect(self.auth_url())
                                  ^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/social_core/backends/oauth.py", line 183, in auth_url
    token = self.set_unauthorized_token()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/social_core/backends/oauth.py", line 240, in set_unauthorized_token
    token = self.unauthorized_token()
            ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/lingua-libre/env/lib/python3.11/site-packages/social_core/backends/mediawiki.py", line 60, in unauthorized_token
    raise AuthException(self, response.content.decode())
social_core.exceptions.AuthException: Error: An error occurred in the OAuth protocol: Invalid consumer
[12/Feb/2025 15:00:52] "GET /oauth/login/mediawiki/ HTTP/1.1" 500 95180

Issue:

While setting up the repo we have to set up our own config.ini file That has the [oauth] section which has 3 fields as shown below

[oauth]
key=
secret=
provider_url=https://commons.wikimedia.beta.wmflabs.org/w/index.php

To generate the key and secret, we need to fill out the form at OAuth Consumer Registration. This form is linked from the MediaWiki OAuth Developer Guide.

  • The Applicable project dropdown lists various Wikimedia projects.
  • Currently, it allows selecting commons.wikimedia.org, but commons.wikimedia.beta.wmflabs.org is not available as an option.
  • As a result, we must generate the OAuth key and secret for commons.wikimedia.org instead.
  • However, using these credentials in config.ini results in an error.

Solution:

To resolve this, update the provider_url in your configuration to: https://commons.wikimedia.org/w/index.php

This ensures compatibility and prevents authentication issues.

Merge request reports

Loading