Unable to fetch collections, HTTP Error 403: Forbidden

Hi,
I’m using ansible-core 2.14.6 and have few collections in requirements.yml which I need to download. Everything was working fine until upgrade of ansible galaxy web site :slight_smile:

I’ve seen that there were changes and tried to remove old token files, tried to generate new token, but always getting 403 error when I’m trying to fetch the collections.

Here is how it looks:

ansible.cfg v1 Not working

[galaxy]
server_list = release_galaxy

[galaxy_server.release_galaxy]
url=https://galaxy.ansible.com/api/
token=xxxx

ansible.cfg v2 Not working

[galaxy]
server_list = release_galaxy

[galaxy_server.release_galaxy]
url=https://galaxy.ansible.com/api/
#token=xxxx

**ansible.cfg v3 Not working **

#[galaxy]
#server_list = release_galaxy

#[galaxy_server.release_galaxy]
#url=https://galaxy.ansible.com/api/
#token=xxxx

requirements.yml

---
collections:
  # Install collections from Ansible Galaxy.
  - name: community.hashi_vault
    # source: https://galaxy.ansible.com
    version: 1.3.2
  - name: kubernetes.core
    # source: https://galaxy.ansible.com
    version: 2.2.0
  - name: community.general
    version: 3.6.0
  - name: community.vmware
    version: 1.14.0

ansible-galaxy install -vvv -c -r requirements.yml --force-with-deps

ansible-galaxy   install -vvv -c -r requirements.yml --force-with-deps
ansible-galaxy [core 2.14.6]
  config file = /home/xxxx/git/xxxx-ansible-repo/ansible.cfg
  configured module search path = ['/home/xxxx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/xxxx/.local/share/virtualenvs/xxxx-ansible-repo-NHoHQRrD/lib/python3.9/site-packages/ansible
  ansible collection location = /home/xxxx/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/xxxx/.local/share/virtualenvs/xxxx-ansible-repo-NHoHQRrD/bin/ansible-galaxy
  python version = 3.9.16 (main, May 22 2023, 18:14:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] (/home/xxxx/.local/share/virtualenvs/xxxx-ansible-repo-NHoHQRrD/bin/python)
  jinja version = 3.1.2
  libyaml = True
Using /home/xxxx/git/xxxx-ansible-repo/ansible.cfg as config file
Reading requirement file at '/home/xxxx/git/xxxx-ansible-repo/requirements.yml'
Starting galaxy collection install process
Found installed collection community.hashi_vault:1.3.2 at '/home/xxxx/.ansible/collections/ansible_collections/community/hashi_vault'
Found installed collection kubernetes.core:2.2.0 at '/home/xxxx/.ansible/collections/ansible_collections/kubernetes/core'
Process install dependency map
Opened /home/xxxx/.ansible/galaxy_token
Starting collection install process
Downloading https://galaxy.ansible.com/api/v3/plugin/ansible/content/published/collections/artifacts/community-hashi_vault-1.3.2.tar.gz to /home/xxxx/.ansible/tmp/ansible-local-99203leaae8xv/tmp29be6vo4/community-hashi_vault-1.3.2-gxs1z5yc
ERROR! Failed to download collection tar from 'release_galaxy' due to the following unforeseen error: HTTP Error 403: Forbidden. HTTP Error 403: Forbidden

If I point ansible.cfg to the old galaxy, I don’t get 403 errors :

[galaxy]
server_list = release_galaxy

[galaxy_server.release_galaxy]
url=https://old-galaxy.ansible.com/api/

What am I doing wrong?

I’m getting a similar error but with AWX 23.3.0

ERROR! Error when finding available api versions from server0 (https://galaxy.ansible.com/) (HTTP Code: 403, Message: Forbidden)

To fix the 403 error I had to get a new token from: Galaxy NG

and put it in the registry credential that is set in the AWX “organization” (#/organizations ) Galaxy credential, the problem is that I didn’t had the permission to see that credential… After fixing that I ended up in this issue, Skipping Galaxy server https://galaxy.ansible.com/api/ , that has been fixed updating to the latest AWX.