Can any one post a REST api for golang- keycloak authentication

I am trying to access a keycloak user authentication with below mentioned code.

package main

import (



func main() {
// Keycloak configuration
keycloak := gocloak.NewClient(“http://localhost:8080/auth”)
realm := “myrealm”
clientID := “myapp-client”
username := “myuser”
password := “user-password” // The user’s actual password

// Authenticate the user using ROPC (Resource Owner Password Credentials)
token, err := keycloak.Login(context.TODO(), clientID, clientSecret, realm, username, password)
if err != nil {
	fmt.Println("Error authenticating:", err)

// Use the obtained access token for further API requests
fmt.Println("Access Token:", token.AccessToken)


however getting following error:

Error authenticating: 404 Not Found: RESTEASY003210: Could not find resource for full path: http://localhost:8080/auth/auth/realms/myrealm/protocol/openid-connect/token

Please help.

A very similar error can be found on one of the (closed) GitHub-issues of the project:

Have you tried testing the URL with curl (as they do in that issue)?

Thanks a lot. A curl and a modified url worked for me.
keycloakURL := “http://localhost:8080/realms/{realm_name}/protocol/openid-connect/token

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.