[Galaxy] Unable to get access token (HTTP Code: 400, Message: Bad Request)

ansible-core: 2.21.5
ansible-builder: 3.2.0

Since a few days, I am unable to build new execution environments with the command

ansible-builder build --container-runtime=docker --context="/ee/context" --file="/ee/files/definition/file.yml" --tag="tag_name:version" -v3
...
#29 [galaxy 6/6] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install  -r requirements.yml --collections-path "/usr/share/ansible/collections"
#29 0.641 [WARNING]: Deprecation warnings can be disabled by setting `deprecation_warnings=False` in ansible.cfg.
#29 0.641 [DEPRECATION WARNING]: PARAMIKO_HOST_KEY_AUTO_ADD option. Reason: This option was moved to the plugin itself
#29 0.641 Alternatives: Use the option from the plugin itself. This feature will be removed from ansible-core version 2.20.
#29 0.641 
#29 1.238 [ERROR]: Unable to get access token (HTTP Code: 400, Message: Bad Request)
#29 1.238 
#29 1.238 Traceback (most recent call last):
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/token.py", line 91, in get
#29 1.238     resp = open_url(to_native(self.auth_url),
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/module_utils/urls.py", line 1018, in open_url
#29 1.238     return Request().open(method, url, data=data, headers=headers, use_proxy=use_proxy,
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/module_utils/urls.py", line 922, in open
#29 1.238     r = urllib.request.urlopen(request, None, timeout)
#29 1.238         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 216, in urlopen
#29 1.238     return opener.open(url, data, timeout)
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 525, in open
#29 1.238     response = meth(req, response)
#29 1.238                ^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 634, in http_response
#29 1.238     response = self.parent.error(
#29 1.238                ^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 563, in error
#29 1.238     return self._call_chain(*args)
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 496, in _call_chain
#29 1.238     result = func(*args)
#29 1.238              ^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 643, in http_error_default
#29 1.238     raise HTTPError(req.full_url, code, msg, hdrs, fp)
#29 1.238 urllib.error.HTTPError: HTTP Error 400: Bad Request
#29 1.238 
#29 1.238 During handling of the above exception, another exception occurred:
#29 1.238 
#29 1.238 Traceback (most recent call last):
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/api.py", line 93, in wrapped
#29 1.238     data = self._call_galaxy(n_url, method='GET', error_context_msg=error_context_msg, cache=True)
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/module_utils/api.py", line 168, in run_function
#29 1.238     return call_retryable_function()
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/api.py", line 400, in _call_galaxy
#29 1.238     self._add_auth_token(headers, url, required=auth_required)
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/api.py", line 449, in _add_auth_token
#29 1.238     headers.update(self.token.headers())
#29 1.238                    ^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/token.py", line 115, in headers
#29 1.238     headers['Authorization'] = '%s %s' % (self.token_type, self.get())
#29 1.238                                                            ^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/token.py", line 97, in get
#29 1.238     raise GalaxyError(e, 'Unable to get access token')
#29 1.238 ansible.galaxy.api.GalaxyError: Unable to get access token (HTTP Code: 400, Message: Bad Request)
#29 1.238 
#29 1.238 During handling of the above exception, another exception occurred:
#29 1.238 
#29 1.238 Traceback (most recent call last):
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/token.py", line 91, in get
#29 1.238     resp = open_url(to_native(self.auth_url),
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/module_utils/urls.py", line 1018, in open_url
#29 1.238     return Request().open(method, url, data=data, headers=headers, use_proxy=use_proxy,
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/module_utils/urls.py", line 922, in open
#29 1.238     r = urllib.request.urlopen(request, None, timeout)
#29 1.238         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 216, in urlopen
#29 1.238     return opener.open(url, data, timeout)
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 525, in open
#29 1.238     response = meth(req, response)
#29 1.238                ^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 634, in http_response
#29 1.238     response = self.parent.error(
#29 1.238                ^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 563, in error
#29 1.238     return self._call_chain(*args)
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 496, in _call_chain
#29 1.238     result = func(*args)
#29 1.238              ^^^^^^^^^^^
#29 1.238   File "/usr/lib64/python3.11/urllib/request.py", line 643, in http_error_default
#29 1.238     raise HTTPError(req.full_url, code, msg, hdrs, fp)
#29 1.238 urllib.error.HTTPError: HTTP Error 400: Bad Request
#29 1.238 
#29 1.238 During handling of the above exception, another exception occurred:
#29 1.238 
#29 1.238 Traceback (most recent call last):
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/cli/__init__.py", line 660, in cli_executor
#29 1.238     exit_code = cli.run()
#29 1.238                 ^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/cli/galaxy.py", line 734, in run
#29 1.238     return context.CLIARGS['func']()
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/cli/galaxy.py", line 102, in method_wrapper
#29 1.238     return wrapped_method(*args, **kwargs)
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/cli/galaxy.py", line 1399, in execute_install
#29 1.238     self._execute_install_collection(
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/cli/galaxy.py", line 1448, in _execute_install_collection
#29 1.238     install_collections(
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 735, in install_collections
#29 1.238     dependency_map = _resolve_depenency_map(
#29 1.238                      ^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/collection/__init__.py", line 1855, in _resolve_depenency_map
#29 1.238     return collection_dep_resolver.resolve(
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/resolvelib/resolvers/resolution.py", line 601, in resolve
#29 1.238     state = resolution.resolve(requirements, max_rounds=max_rounds)
#29 1.238             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/resolvelib/resolvers/resolution.py", line 434, in resolve
#29 1.238     self._add_to_criteria(self.state.criteria, r, parent=None)
#29 1.238   File "/usr/local/lib/python3.11/site-packages/resolvelib/resolvers/resolution.py", line 125, in _add_to_criteria
#29 1.238     matches = self._p.find_matches(
#29 1.238               ^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/dependency_resolution/providers.py", line 477, in find_matches
#29 1.238     match for match in self._find_matches(list(requirements[identifier]))
#29 1.238                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/dependency_resolution/providers.py", line 253, in _find_matches
#29 1.238     coll_versions = [] if preinstalled_candidates else self._api_proxy.get_collection_versions(first_req)  # type: t.Iterable[t.Tuple[str, GalaxyAPI]]
#29 1.238                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 103, in get_collection_versions
#29 1.238     return set(
#29 1.238            ^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 103, in <genexpr>
#29 1.238     return set(
#29 1.238               ^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 85, in _get_collection_versions
#29 1.238     raise last_error
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/collection/galaxy_api_proxy.py", line 64, in _get_collection_versions
#29 1.238     versions = api.get_collection_versions(requirement.namespace, requirement.name)
#29 1.238                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/api.py", line 103, in wrapped
#29 1.238     data = self._call_galaxy(n_url, method='GET', error_context_msg=error_context_msg, cache=True)
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/module_utils/api.py", line 168, in run_function
#29 1.238     return call_retryable_function()
#29 1.238            ^^^^^^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/api.py", line 400, in _call_galaxy
#29 1.238     self._add_auth_token(headers, url, required=auth_required)
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/api.py", line 449, in _add_auth_token
#29 1.238     headers.update(self.token.headers())
#29 1.238                    ^^^^^^^^^^^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/token.py", line 115, in headers
#29 1.238     headers['Authorization'] = '%s %s' % (self.token_type, self.get())
#29 1.238                                                            ^^^^^^^^^^
#29 1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/token.py", line 97, in get
#29 1.238     raise GalaxyError(e, 'Unable to get access token')
#29 1.238 ansible.galaxy.api.GalaxyError: Unable to get access token (HTTP Code: 400, Message: Bad Request)
#29 1.238 
#29 1.238 Starting galaxy collection install process
#29 1.238 Process install dependency map
#29 ERROR: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 1
------
 > [galaxy 6/6] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install  -r requirements.yml --collections-path "/usr/share/ansible/collections":
1.238                    ^^^^^^^^^^^^^^^^^^^^
1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/token.py", line 115, in headers
1.238     headers['Authorization'] = '%s %s' % (self.token_type, self.get())
1.238                                                            ^^^^^^^^^^
1.238   File "/usr/local/lib/python3.11/site-packages/ansible/galaxy/token.py", line 97, in get
1.238     raise GalaxyError(e, 'Unable to get access token')
1.238 ansible.galaxy.api.GalaxyError: Unable to get access token (HTTP Code: 400, Message: Bad Request)
1.238 
1.238 Starting galaxy collection install process
1.238 Process install dependency map
------
Dockerfile:54
--------------------
  52 |     RUN mkdir -p /usr/share/ansible
  53 |     RUN ansible-galaxy role install $ANSIBLE_GALAXY_CLI_ROLE_OPTS -r requirements.yml --roles-path "/usr/share/ansible/roles"
  54 | >>> RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path "/usr/share/ansible/collections"
  55 |     
  56 |     # Builder build stage
--------------------
ERROR: failed to build: failed to solve: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 1

ansible-builder

same issue with ansible-builder 3.1.0

That error can only happening when attempting to authenticate against console.redhat.com via the ansible-galaxy cli.

The only thing I can recommend is to verify your credentials and that builder is configured to properly inject them.