Friday, October 10, 2025
HomeGolangCan anybody submit a REST api for golang- keycloak authentication - Getting...

Can anybody submit a REST api for golang- keycloak authentication – Getting Assist


I’m attempting to entry a keycloak person authentication with under talked about code.

bundle major

import (
“context”
“fmt”

"github.com/Nerzal/gocloak/v9"

)

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

// Authenticate the person utilizing ROPC (Useful resource Proprietor Password Credentials)
token, err := keycloak.Login(context.TODO(), clientID, clientSecret, realm, username, password)
if err != nil {
	fmt.Println("Error authenticating:", err)
	return
}

// Use the obtained entry token for additional API requests
fmt.Println("Entry Token:", token.AccessToken)

}

nevertheless getting following error:

Error authenticating: 404 Not Discovered: RESTEASY003210: Couldn’t discover useful resource for full path: http://localhost:8080/auth/auth/realms/myrealm/protocol/openid-connect/token

Please assist.

A really comparable error will be discovered on one of many (closed) GitHub-issues of the undertaking: https://github.com/Nerzal/gocloak/points/346

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

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

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments