Keycloak Admin REST API | Create Users | Add Roles

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today we are going to talk about key clock user management using admin API mainly I am going to start a new key clock server and do some testing using Postman collection mainly I am going to create new user and add the sign roles to user using rest API this system my main aim today and I already installed it install the gate clock server in my last video you can check it if you need more details I will quickly install a new account go to key clock main server and this is the download go to download and download this zip file after downloading it please extracted it I already did it let me go to it and this is that folder go to it and go this bin and open CMD in here then you have to start click key clock server to that type this command okay see that and start View and you can specific specific airport if you not don't need you can do that also then it will open in 880 Port but if you need you any specific Port just do this http Port equal 1890 I will open a clock survey in Port 89. then start it yes it's already started then go to browser and type localhost and Port 8090 my kids and it will open this interface this is the admin panel for Key Club you have to first create account if you are login First Time and I will create admin with me then create account after creating account please log in using this admin console and type work experiences which you created now this is this is a fresh key clock account and you have to create a vellum go to this drop down and click this create level up and I will create a demo well just type anything you need after creating it make sure to select it from here demo account then you have to create a client we are using client to communicate with this key clock account mainly go to this client section and create a new plan I will create a demo client and let's see next button and you have to give some authorizations to access this endpoint so you have to give this authorization access for this plan next you don't need to configure this configuration for now just save it after creating take a three clock account just go to this client section and see here your demo account is already created now you can see there are those assigned to this and users and every detail sign here now let me try to login using Postman collection to this using Personal Collection this client just open your Postman and create a new collection I will block October view this name and next step is to yeah and then you I will create the login name for it and I did this example in last video also you can check it and first thing is you have to add a hostname I am creating a hostname as variable host and then and you can get this details from we have the outside window in here there is Vellum settings go to it and here open ID and point configuration click it here you can get details here I am using going to use this token endpoint this one just copy it login and paste it and you can pass these sets up parameter it's a host name and next one is this Vellum name you can pass it also and next one is then you need that client ID and client secret just type and ID and Secret these are the main variables we're going to save because we are using those variables again and again it is easier to see how we take and after that we are going to login for login just going to body and select this form unicode and you have to pass gun type and client ID and Secret here we already saved plants required and client ID let me show you how to get these clients request and client ID just go to your admin panel in client section go to your client and in my case demo client and go to this credential step here you can see client secret copy it and editing key clock and explain SQL and client ID go to this settings tab and here demo client it is your client ID and edit client ID that's it now go to login endpoint and here you can see your detail sign here client ID to answer yeah it's circuit now you have to give Grant type so in here we are going to use client ID and client secret so we have to give here client Credence cells Within chills and financials that's it let's test it yeah yeah it's need to be a post request and here you will get a access token just copy this one and let's check it in our browser jwp I go to the site and you can take a look here token body here you can see you can get on every all details and scope and everything you can find from here and yeah that's it for now it's already working fine and another one thing is we have to save this token into our local variable collection variable let me do that and go to this settings tab and you have to type PM Dot and collection variable you have to set it we are going to set access token and variable is PM from response dot Json and we are getting access talk that's it and from this what we are going to do is when we are login we are try to save this access token in collection variable so we have to add this into collection variable go to our collection again edit here that's it for now let me try to log it again go to that and here you can see it's already saved in this variable then we can use this and that's it for our login endpoint our next cases we are going to create here you can see that inside yeah you have users we have to add users to this client so we are going to use Creator users using rest API and for that click lock provide the admin API which we can use to when we are going to use rest API we can use that admin API to integrate with key clock so let me go to that site here you can type key clock admin API yes this is it if you need you can yeah yeah it's the main you can go through this this is the API test API which we can use when AI without using interface if you need to integrate with this our app then we can use this rest API first I am going to create a user account for this you have to go try these users here you can create a user account using this one and this and parameters are path parameters and body parameters is user represent yeah you can get all these all details on this site and let me do create that account ah first you have let me create a new request if the post request and here you have to provide your URL for that let me get the URL from site here this is the URL and first thing is we have to and do a basic us also my basic URL is hostname slash and then you have to add a to access admin you have to add this admin I will provide all those details in link you can get copy paste from there and next one is well now balance and users this is the endpoint for create a new account foreign Docker access to when it's done for now and the body it is a Json and I will copy my body and explain it I will provide it I already did this part this is my main features we have to add in here create an account this enable mean we are giving access to that user and email verification mean if that true or false an email username password those are the main configuration we have and credentials mean you are going to give credentials that password to access your account this is it for now and attribute you can give some key value pair to identify this user and that's it for now I will give this as a create account create question and let me test it sorry I did one mistake you have to give this swellum also after the alarm then text it and it's not working I will explain why yeah it's not working because let me go to this login account and paste it and here in this user yeah this is all the we haven't give our account management feature so it's not EX this user cannot create new users so we have to use account management for that you go to here and clients and demo clients and go to this service account loss here you have to assign award set client and check where is account manager user account management or you can give admin access here LM admin access assign it now let's login it again and check this body here then you can see here there are many features now now let's try to login it again and learn this endpoint yeah it's created let me go to site and go to users here yeah it's already created and attribute also there are we added attribute and credentials also added and so all mapping is not in here yeah this is the basic part of creating account now next part is we going to assign a new role and for that let me create a new role you have to go to this client section go to demo client and LOLs let me create a new for test it I will create a quickly from here I will click admin role save it and I'm going to create another role super easy or yeah save it yeah you can see it now in client area girls here you have created two roles now I am going to access these slots for that to have another endpoint you can get all these details from here I will already edit it so I am copying from there just creator new request and for get all laws you have to access this one it is we have to change this to our details first name and just you have to save it first and this is our volume and plan two ID this client uid let me show you we have to add it into here and this client uid mean we have to get it from here when we are login to site just go to your client area and go to a specific client here you after this client part there is a uid this is your client ID just copy this and paste it to here and that's it now your client and your goals yeah this endpoint will will give you all goals you created you have to authenticate it and authenticate it go to body and test it here let's give all users you have results you created super user role admin Zone and other Lots also and click noise yeah next step is we are going to assign all to our user we have created new user test admin and goals so I am going to create that term for it let me create a new and the request and I will copy it also from this one before that there is another endpoint which we can get um all details by name called name let me call that first this endpoint yeah we have to change first name envelope name and next one is here you can get using the same point you can get your all details by call name and there is I will give this admin role I am going to get these details about this and you have to add authorization as well and check it here it will give you all details about admin it will helpful for you when you are working with that app and that's it I will save it this is get all my an enemy I will provide this collection then you can work use do your testing using it you don't need to find get these urls and next one is I am going to assign a user to go add a new one and assign Lord will set and this endpoint is let me copy it this one it is a post and how to host and also yeah let's see then you have to after user you have to provide this your user ID also you can get use ID from go to one of user and this here you side this is your use ID copied India use ID and all mapping client and client type that's it and you have to authorize it and in your body it is all Json object you have to give your array of flows I will provide one example here this is your array of flow let me I am going to ask you this is a admin I will give access this one here what we going to do is we give this user admin Dot let me post it yeah you have to this will expire correctly so you have to give more expiration if you need and run it again yeah create let me go to site and go to this user yeah already added let me give another one and here we can use super user let me take it from here it will give you super thought and go to here at this side yeah go to site and click it sorry you have to let me install MacBook here it's already working Now using this basic rest apis you can do anything related to most of the cases you can create a new account and assigning a role and login using this main endpoint you can do most of the config configurations related to your apps also and that's it for now thank you
Info
Channel: Web Tech Stack
Views: 7,077
Rating: undefined out of 5
Keywords: keycloakapi, keycloak, postman
Id: 8YPYjjH8awI
Channel Id: undefined
Length: 24min 1sec (1441 seconds)
Published: Thu Jul 06 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.