How to Get Keycloak Access Token Using Postman
1. Introduction In this article, I will share how we can generate a Keycloak access token using Postman. 1.1 Prerequisites You...
https://www.czetsuyatech.com/2021/07/keycloak-get-access-token-using-postman.html
1. Introduction
In this article, I will share how we can generate a Keycloak access token using Postman.
1.1 Prerequisites
- You must have a docker installed.
- You must have installed Postman.
2. Setup Keycloak
Before we begin, we need to run an instance of Keycloak in docker first.
docker run -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -p 8081:8080 -d jboss/keycloak:10.0.2Keycloak should run on port 8081.
Now, go to your browser and open http://localhost:8081 and you should arrive in Keycloak admin page.
3. Create a Keycloak Realm and Client
Next, we need to create the realm and client that we will be using to generate a token.
During the first serving of the page, Keycloak will ask you to save an admin user and password.
- Login to Keycloak.
- In the left panel, hover to Master, and click Add Realm.
- Enter czetsuyatech.
- On the left panel, click Clients.
- On the right side, click Create.
- Enter auth in the client id and hit Save.
- In the client detail page:
- Set Access Type=confidential.
- Valid Redirect URIs=* (for debugging purposes only)
- Web Origins=* (for debugging purposes only)
- *Make sure to secure items 2 and 3 in production.
- Copy the Secret value in the Credentials tab, we will use it later.
4. Create a Keycloak User
- On the left panel, under Manage click Users.
- Click Add User.
- In the username field, enter czetsuyatech and hit save.
- Open the Credentials tab, set the password to czetsuyatech, switch Temporary to OFF.
- Click Set Password.
5. Create a Postman Request
Open Postman and create a post request with the following form of URL encoded values.
- POST request URL: http://192.168.1.101:8081/auth/realms/czetsuyatech/protocol/openid-connect/token
- Body Parameters
- x-www-form-urlencoded
- client_id=auth
- username=czetsuyatech
- password=czetsuyatech
- grant_type=password
- client_secret=[Get the value from step 3.8]
Post a Comment