Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseUrl isn't getting used #16931

Closed
stevehogdahl opened this issue May 23, 2020 · 7 comments
Closed

BaseUrl isn't getting used #16931

stevehogdahl opened this issue May 23, 2020 · 7 comments
Labels
area/admin/client-js kind/bug Categorizes a PR related to a bug team/ui

Comments

@stevehogdahl
Copy link

stevehogdahl commented May 23, 2020

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);
@Kinrany
Copy link
Contributor

Kinrany commented May 25, 2020

I'm getting the same error while using keycloak/keycloak-nodejs-connect, so your issue might be caused by something else

@Kinrany
Copy link
Contributor

Kinrany commented May 25, 2020

In my case I was trying to write a test with request(app).get("some/route"). The route must start with a /.

@manuserranog
Copy link

Same error

@patrykwegrzyn
Copy link

patrykwegrzyn commented Jun 1, 2020

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);

@stevehogdahl
Copy link
Author

stevehogdahl commented Jun 2, 2020

@patrykwegrzyn thank you, I'll give that a try.

@itsalb3rt
Copy link

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);

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"

@stianst stianst added the kind/bug Categorizes a PR related to a bug label Nov 11, 2021
@jonkoops jonkoops transferred this issue from keycloak/keycloak-nodejs-admin-client Nov 24, 2022
@ssilvert ssilvert transferred this issue from keycloak/keycloak-ui Feb 8, 2023
@ssilvert ssilvert added this to the Backlog milestone Feb 20, 2023
@edewit
Copy link
Contributor

edewit commented Mar 16, 2023

closing

@edewit edewit closed this as not planned Won't fix, can't repro, duplicate, stale Mar 16, 2023
@stianst stianst removed this from the Backlog milestone Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/admin/client-js kind/bug Categorizes a PR related to a bug team/ui
Projects
None yet
Development

No branches or pull requests

9 participants