Nerzal/gocloak

Question/Help: Trying to get `Realm -> Clients -> Credentials -> Secret`

dthisner opened this issue · 2 comments

I am trying to retrive a clients secret, when I am listing the clients, only one that is showing up is Dash, I am not seeing dash-backend and dash does not even exist in my client list in the dash realm.

Screenshot 2023-11-24 at 17 39 06

I am logged in as an admin for the Master realm.
When I run:

clients, err := kc.Client.GetClients(kc.Ctx, kc.Token.AccessToken, "dash",
		gocloak.GetClientsParams{
			ClientID: &kc.Info.ClientID,
		},
	)
	if err != nil {
		return err
	}

I only get back 1 client, which is dash

what am I doing wrong? Any help is appreciated :)

Clearly doing something wrong, looked at the example and used it:

	var clientList []*gocloak.Client

	// init map
	var clients = make(map[string]gocloak.Client)

	clientList, err := kc.Client.GetClients(kc.Ctx, kc.Token.AccessToken, "dash",
		gocloak.GetClientsParams{},
	)
	if err != nil {
		return err
	}

	for _, c := range clientList {
		fmt.Println(*c.ID)
		clients[*c.ClientID] = *c
	}

Now I am getting the correct values :)

That did it, thanks :D