Home > Blockchain >  I can't get X-Auth-Token from keyrock
I can't get X-Auth-Token from keyrock

Time:01-17

I am making a project for uni. I'm making the following request directly to keyrock using .http to get the default admin's X-Auth-Token:

POST http://localhost:3005/v1/auth/tokens
Content-Type: application/json

{"email":"[email protected]","password":"1234"}

The result is this:

{
  "error": {
    "message": "Invalid email or password",
    "code": 401,
    "title": "Unauthorized"
  }
}

The request has correct parameters. I initialized the mysql database and added the user with those credentials as an admin user. I also checked inside the container and the user exists and has these credentials. I checked if keyrock is connected to mysql and I'm certain it is otherwise docker compose waits until keyrock connects. The docker compose file is below and I made it using the step-by-step guide in github. Here it is:

version: "3.8"

networks:
  idm_network:
    driver: bridge

#project images
services:
.
.
.
  mysql:
      build: ./mysql         
      command:
      - "--default-authentication-plugin=mysql_native_password"
      networks:
        - idm_network
      volumes:
        - mysqlVolume:/var/lib/mysql
      environment:
        - MYSQL_ROOT_PASSWORD=idm
        - MYSQL_ROOT_HOST=%
        #- MYSQL_USER=root
        #- MYSQL_DATABASE=idm
        

  keyrock:
    image: fiware/idm:7.6.0  
    networks:
        - idm_network
    depends_on:
        - mysql
    ports:
      - "3005:3005"
      - "443:443"
    environment:
        - IDM_DB_HOST=mysql
        - IDM_HOST=http://localhost:3005
        - IDM_PORT=3005
        #- IDM_DB_PASS=secret
        #- IDM_DB_USER=idm
        #- IDM_ADMIN_USER=admin
        #- [email protected]
        #- IDM_ADMIN_PASS=1234
.
.
.
#project volumes
volumes:
  mysqlVolume:
  mongoOrionVolume:
  mongoDataVolume:

I've tried both with and without these commented env variables and both times it didn't work. The problem is if I can't solve this I can't test anything in my project server, logic, etc. Does anyone know what causes this issue?

Thanks.

CodePudding user response:

There was a problem with my request. The proper request is:

curl --sslv3 --include \
     --request POST \
     --header "Content-Type: application/json" \
     --data-binary "{
  \"name\": \"[email protected]\",
  \"password\": \"1234\"
}" \
'http://localhost:3005/v1/auth/tokens'

and then I converted that into node axios with postman. In this site exist all correct requests for Keyrock: https://keyrock.docs.apiary.io/#

  • Related