0

I am using keycloak API:

http://localhost:8080/auth/admin/realms/master/users for creating user

it's working fine but I need to add user consent with this API or by any alternative API(s), How can I do this,

Thanks in advance.

Dhaval
  • 868
  • 12
  • 22

1 Answers1

0

You can try the following, although I am not 100% it will work:

If you look at the Keycloak Admin REST API you can see that for the endpoint:

POST /{realm}/users

which is the endpoint that you are using to create the users you can pass the following body parameters:

UserRepresentation

which is composed by (among others) the following (optional) field :

clientConsents <UserConsentRepresentation> array

Therefore, you can create the user already with its consents.

I would suggested you to first create a dummy user, create the consents via Admin Console, then call:

GET /{realm}/users/{id} 

inspect how the response looks, so that you know how the body content of the POST /{realm}/users should look like.

dreamcrash
  • 47,137
  • 25
  • 94
  • 117
  • Unfortunately that wouldn't allow to programatically mimic a user consent as users are already created... I searched in the API and there seems to be no endpoint to edit consents... Any other thoughts? – José Carlos Aug 04 '21 at 14:56