Keycloak 如何使用Nodejs/Nestjs在keydape中创建用户。获取AnyExceptionFilter:exception:JSON未定义
我正在使用nestjs实现用于在KeyClope中创建用户的API。我错过什么了吗? 我这里有两个问题Keycloak 如何使用Nodejs/Nestjs在keydape中创建用户。获取AnyExceptionFilter:exception:JSON未定义,keycloak,nestjs,createuser,Keycloak,Nestjs,Createuser,我正在使用nestjs实现用于在KeyClope中创建用户的API。我错过什么了吗? 我这里有两个问题 我在firstName和lastName中得到了未定义的 AnyExceptionFilter:exception:JSON未定义,即使我对firstName和lastName使用了伪数据 谁能帮我一下我犯的错误吗 async createOpsUser(body: IUserRepresentation) { return new Promise(async (resolve,
async createOpsUser(body: IUserRepresentation) {
return new Promise(async (resolve, reject) => {
// url: http://localhost:9080/auth/realms/master/users
const bodyReq = {
firstName: body.firstName, // getting undefined
lastName: body.lastName, // getting undefined
enabled: true,
};
const auth = await this.getAdminAuth();
const req = {
url: `${this.baseUrl}/realms/${this.realmName}/users`,
auth: {
bearer: auth.access_token,
},
body: bodyReq,
method: 'POST',
json: true,
};
request(req, (err, resp, payload) => {
if (err) {
return reject(err);
}
if (resp.statusCode !== 204) {
return reject(payload);
}
resolve(true);
});
});
}
我想我们需要更多的上下文,你能展示一下
createOpsUser
是如何被调用的吗body
很可能是一个空对象,但是如果没有更多的上下文,就不可能看到为什么请看一看