Nerzal / gocloak

golang keycloak client
Apache License 2.0
1.01k stars 275 forks source link

Failing to set custom Token endpoint #452

Closed ytanne closed 8 months ago

ytanne commented 9 months ago

Describe the bug I am failing to set custom token endpoint.

To Reproduce Steps to reproduce the behavior:

  1. Create new client:
    
    // values are just examples
    hostname = "https://test.domain"
    customEndpoint = "test/path/to/token"

client := gocloak.NewClient(hostname, gocloak.SetTokenEndpoint(customEndpoint)) token, err := client.LoginClient(context.Background(), username, password, realm) if err != nil { log.Println(err) os.Exit(1) }

2. Run: 
```bash
go run test.go
  1. Observe output:
    404 Not Found: RESTEASY003210: Could not find resource for full path: https://test.domain/realms//test/path/to/token

Expected behavior I expect to get the token

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Nerzal commented 8 months ago

What keycloak version are u using?

ytanne commented 8 months ago

I have found the source of the issue. The realm that I was passing was empty. Anyway, I wonder why you use strings.Join in makeURL instead of url.JoinPath?