Skip to content

Commit ecb1dee

Browse files
author
Harald Krämer
committed
fix: validation errors when accessing keycloak 25
1 parent a88d67f commit ecb1dee

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

internal/authenticator/authenticator.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,18 @@ func (c *AuthenticatorClient) Authenticate(ctx context.Context) (string, error)
3535
return c.Token, nil
3636
}
3737

38-
tokenUrl := fmt.Sprintf("%s/protocol/openid-connect/token", c.URL)
38+
tokenUrl := fmt.Sprintf("%s/protocol/openid-connect/token", strings.TrimRight(c.URL, "/"))
3939
form := url.Values{}
4040
form.Add("grant_type", "client_credentials")
41+
form.Add("client_id", c.ApplicationUsername)
42+
form.Add("client_secret", c.ApplicationPassword)
4143
req, err := http.NewRequestWithContext(ctx, "POST", tokenUrl, strings.NewReader(form.Encode()))
4244
tflog.Info(ctx, "creating request", map[string]interface{}{"url": tokenUrl, "err": err})
4345

4446
if err != nil {
4547
return "", err
4648
}
4749

48-
req.SetBasicAuth(c.ApplicationUsername, c.ApplicationPassword)
4950
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
5051

5152
resp, err := c.Client.Do(req)

0 commit comments

Comments
 (0)