Home >Backend Development >Golang >Keycloak with krakend giving error 403 after logging in correctly?

Keycloak with krakend giving error 403 after logging in correctly?

王林
王林forward
2024-02-14 10:51:091143browse

正确登录后,带有 krakend 的 Keycloak 给出错误 403?

php editor Apple introduced that when you use Keycloak with krakend to log in correctly, you may sometimes encounter error 403. A 403 error usually means that the server rejected the request, which may be caused by insufficient permissions or blocked access. There are several ways to resolve this issue, including checking permission settings, confirming the validity of login credentials, checking network connections, etc. Through step-by-step troubleshooting, this problem can be effectively solved to ensure smooth access to the required resources.

Question content

Hi, I'm trying to authenticate using Keycloak and Krakend, I can send my request, log in, then when I try to access the resource (using Insomnia) I get:

403 Forbidden: No response body returned.

I don't know why this is happening, please help!

This is my Krakend.json configuration file:

82BC1186967c2a759b3162034d07be32

In Keycloak I created my realm, user with credentials (with admin rights) and client, I think this is correct because my login with access token works fine, after logging in I get 403.

This is the service I wrote in go:

func JSONHandler(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"ciao": "ciao"})
}

func Init() {
    router := gin.Default()
    router.Use(middlewares.CORS())
    router.GET("/api", JSONHandler)
    err := router.Run(":8080")
    if err != nil {
        log.Fatal("Oh no")
    }
}

Solution

Modify fields:

"$schema": "https://www.krakend.io/schema/v3.json"

to

"$schema": "https://www.krakend.io/schema/v2.4.3.json"

Solved my problem!

The above is the detailed content of Keycloak with krakend giving error 403 after logging in correctly?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete