本文介绍了我应该使用哪个凭证来生成令牌,然后使用 Postman 在 Keycloak DB 中创建用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I have the same problem like this: Create a new user in Keycloak using Postman

So, I also want to create a user, and I'm also getting 401, unauthorized. So I must using wrong token!So how I created token?

In my case:I've created a new Realm, called "Lifetrenz"In this Realm, I've created a user called: "Test"username & password: testclient_id : I created lifetrenz-client-1grant_type : password.


I know that I should not use already created user credentials, then what should I use? If I use my admin credentials (what I used to try login in Keycloak dashboard) then saying invalid grant / credentials.

Postman screenshot:

Two problems:

  1. If I use admin credentails to generate token, then I'm getting 400 invalid grant / credentials
  2. If I use user credential to generate token, it'll generate, then while creating user, I'm getting 401, unauthorized access.


FYI:

How I create user:URL: http://localhost:8080/auth/admin/realms/Lifetrenz/usersand passing Beared token from Auth - Type

解决方案

I solved by using this SAT API: https://documenter.getpostman.com/view/7294517/SzmfZHnd#0138123a-385c-4f66-8fb5-d26df30247d2 to create token and used this Create User SAT API to Add user.

Note: I passed this body along with Bearer token:Postman - Body - raw ->

{
    "username": "abcd",
    "firstName": "xyz",
    "lastName": "xyz",
    "email": "[email protected]",
    "enabled": "true"
}

I hope someone get help from this.

这篇关于我应该使用哪个凭证来生成令牌,然后使用 Postman 在 Keycloak DB 中创建用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 08:28