cannot create user in the keycloak. Getting 403 status

后端 未结 3 1725
野性不改
野性不改 2021-02-08 19:41

I am trying to access the create a user in the keycloak programmatically. But I am getting 403 as a status code. I am following the below link.

https://technology.first8

相关标签:
3条回答
  • 2021-02-08 19:54

    I faced the same issue. This is how i fixed it.

    1. Create a role that has at least a realm-management role of manage-users

    UI update for server 9.0.2

    1. Go to your client's Scope tab and add the role to your Realm Roles
    0 讨论(0)
  • 2021-02-08 20:10

    I faced the same issue with KeyCloak 9.0.3. What finally worked for me was:

    1. Use the admin-cli client with client credentials on the target realm (where I am trying to create the user)
    curl \
      -d "client_id=admin-cli\
      -d "client_secret=<YOUR_CLIENT_SECRET>" \
      -d "grant_type=client_credentials" \
      "http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/token"
    

    I am not sure why, but using the admin client on the master realm simply did not work for me.

    1. Set up the admin-cli client in the target realm with the role as mentioned in the correct answer above.

    2. In addition to adding the new role to Scope, I also had to add the role to Service Account Roles.

    BTW client credentials access token is not even mentioned as an option in the Admin Rest API docs for Keycloak 9.0.3, but it does work.

    0 讨论(0)
  • 2021-02-08 20:21

    If you are not using admin user from master realm.

    You need to assign proper roles like manage-users role from realm-management client for the user which you are using to get instance the instance of Keycloak.

    0 讨论(0)
提交回复
热议问题