keycloak-nodejs-admin-client
keycloak-nodejs-admin-client copied to clipboard
BaseUrl isn't getting used
I'm getting the following error when calling the auth function:
ERROR Invoke Error { "errorType": "Error", "errorMessage": "connect ECONNREFUSED 127.0.0.1:8080", "trace": [ "Error: connect ECONNREFUSED 127.0.0.1:8080", " at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1107:14)" ] }
It looks like it's trying to hit the default baseUrl even though i passed in a new baseUrl. Code is below:
const KeycloakAdminClient = require('keycloak-admin').default;
const settings = {
baseUrl : config.KeycloakBaseLocation,
username : config.KeycloakUsername,
password : config.KeycloakPassword,
grant_type: 'password',
client_id : 'admin-cli',
realmName : config.KeycloakRealm
}
const client = new KeycloakAdminClient();
await client.auth(settings);
I'm getting the same error while using keycloak/keycloak-nodejs-connect, so your issue might be caused by something else
In my case I was trying to write a test with request(app).get("some/route")
. The route must start with a /
.
Same error
I think example in readme is wrong realm
should be in the auth settings and baseUrl
in the options for client constructor
@stevehogdahl try below it works for me
const KeycloakAdminClient = require('keycloak-admin').default;
const settings = {
username : config.KeycloakUsername,
password : config.KeycloakPassword,
grant_type: 'password',
client_id : 'admin-cli',
realmName : config.KeycloakRealm
}
const client = new KeycloakAdminClient( {
baseUrl: config.KeycloakBaseLocation,
});
await client.auth(settings);
@patrykwegrzyn thank you, I'll give that a try.
I think example in readme is wrong
realm
should be in the auth settings andbaseUrl
in the options for client constructor@stevehogdahl try below it works for me
const KeycloakAdminClient = require('keycloak-admin').default; const settings = { username : config.KeycloakUsername, password : config.KeycloakPassword, grant_type: 'password', client_id : 'admin-cli', realmName : config.KeycloakRealm } const client = new KeycloakAdminClient( { baseUrl: config.KeycloakBaseLocation, }); await client.auth(settings);
No. The REAME is correct, In your case maybe you were using the wrong "realm" and by not putting "realmName" in "KeycloakAdminClient" the library put you the realm "master"