Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login() success get token but Further calling the interface 403 Unkow err #445

Open
xyjboys opened this issue Sep 6, 2023 · 0 comments
Open

Comments

@xyjboys
Copy link

xyjboys commented Sep 6, 2023

Describe the bug
A clear and concise description of what the bug is.

Cant use the GetRealmRoles methods. 403

To Reproduce

client := gocloak.NewClient("http://127.0.0.1:8080/auth")
ctx := context.Background()

token, err := client.Login(ctx, "go-demo", "7VTxDxG4TOrtAert6FvjhMdcZKrYLyXz", "demo", "admin", "123456")
if err != nil {
	panic("Something wrong with the credentials or url")
}
fmt.Println(token)

rptResult, err := client.RetrospectToken(ctx, token.AccessToken, "go-demo", "7VTxDxG4TOrtAert6FvjhMdcZKrYLyXz", "demo")
if err != nil {
	panic("Inspection failed:" + err.Error())
}

if !*rptResult.Active {
	panic("Token is not active")
}

permissions := rptResult.Permissions
fmt.Println(permissions)

user, err := client.GetUserInfo(ctx, token.AccessToken, "demo")
fmt.Printf("user: %v\n", user)

users, err := client.GetRawUserInfo(ctx, token.AccessToken, "demo")
fmt.Printf("users: %v\n", users)


parmas := gocloak.GetRoleParams{}
roles, err := client.GetRealmRoles(ctx, token.AccessToken, "demo", parmas)
fmt.Printf("roles: %v\n", roles)

 for this demo i can login success and get the token userInfo  but  GetUserByID  err 403 

Expected behavior
A clear and concise description of what you expected to happen.

200 status code response of GetUserByID user.

Screenshots
1693988385827

Additional context
Add any other context about the problem here.

gocloak version: 13.8
keycloak version: 22.0.1-2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant