Docker private registry token authentication failed with status: 400 Bad Request

Following is my docker-compose.yml file

version: "3.9"

services:
  registry:
    image: registry:latest
    environment:
      REGISTRY_HTTP_SECRET: b8f62d22-9a3f-4c73-bf5e-e0864b400bc8
      DOCKER_HOST: tcp://docker:2375
      #S3 bucket as docker storage
      REGISTRY_STORAGE: s3
      REGISTRY_STORAGE_S3_ACCESSKEY: XXXXXXXXX
      REGISTRY_STORAGE_S3_SECRETKEY: XXXXXXXXX
      REGISTRY_STORAGE_S3_REGION: us-east-1
      REGISTRY_STORAGE_S3_BUCKET: docker-registry
      #Docker token based authentication
      REGISTRY_AUTH: token
      REGISTRY_AUTH_TOKEN_REALM: "https://api.MY-DOMAIN.com/api/developer-auth/login"
      REGISTRY_AUTH_TOKEN_SERVICE: Authentication
      REGISTRY_AUTH_TOKEN_ISSUER: "Let's Encrypt"
      REGISTRY_AUTH_TOKEN_AUTOREDIRECT: false
      #Letsencrupt certificate
      REGISTRY_AUTH_TOKEN_ROOTCERTBUNDLE: "/certs/live/SUB.MY-DOMAIN.com/fullchain.pem"
      REGISTRY_HTTP_TLS_CERTIFICATE: "/certs/live/SUB.MY-DOMAIN.com/fullchain.pem"
      REGISTRY_HTTP_TLS_KEY: "/certs/live/SUB.MY-DOMAIN.com/privkey.pem"
    ports:
      - 5000:5000

    restart: always

    volumes:
      - "/etc/letsencrypt:/certs"

When I try to login to my API server it return the following error

❯ docker login api.MY-DOMAIN.com

Username: Elda86@yahoo.com

Password:

Error response from daemon: login attempt to https://api.MY-DOMAIN.com/v2/ failed with status: 400 Bad Request

May I know how can I fix the issue.