Hey guys, I tried using the Sdk following this imp...
# talk-keto
f
Hey guys, I tried using the Sdk following this implementation but I always get 404 seems like the version v0.5.2 does not work.
package main
import (
"context"
"fmt"
"os"
ory "<http://github.com/ory/keto-client-go|github.com/ory/keto-client-go>"
)
// Use this context to access Ory APIs which require an Ory API Key.
var namespace = "Blog"
var object = "secret_post"
var relation = "view"
var subjectId = "Bob"
func main() {
payload := ory.CreateRelationshipBody{
Namespace: &namespace,
Object:    &object,
Relation:  &relation,
SubjectId: &subjectId,
}
configuration := ory.NewConfiguration()
configuration.Servers = []ory.ServerConfiguration{
{
URL: "<http://127.0.0.1:4467>", // Write API
},
}
writeClient := ory.NewAPIClient(configuration)
_, r, err := writeClient.RelationshipApi.CreateRelationship(context.Background()).CreateRelationshipBody(payload).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
panic("Encountered error: " + err.Error())
}
fmt.Println("Successfully created tuple")
configuration.Servers = []client.ServerConfiguration{
{
URL: "<http://127.0.0.1:4466>", // Read API
},
}
readClient := client.NewAPIClient(configuration)
check, r, err := readClient.PermissionApi.CheckPermission(context.Background()).
Namespace(*&namespace).
Object(*&object).
Relation(*&relation).
SubjectId(*&subjectId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
panic("Encountered error: " + err.Error())
}
if check.Allowed {
fmt.Println(*&subjectId + " can " + *&relation + " the " + *&object)
}
}
m
Hello @flat-rose-25983 Can you share this as a gist that can be copy&pasted together with some instructions to reproduce? unfortunately Slack handles code not great
f
@magnificent-energy-493 Am using this example code here https://www.ory.sh/docs/keto/self-hosted/go package version go get github.com/ory/keto-client-go@v0.5.2 1.
go mod init main
Create
main.go
-go mod tidy 2. Run the command
go run main.go
to execute the program 3. I got 404 not found I have checked the url that the sdk is using but is not the one am using:
<http://localhost:4466/relation-tuples/check/openapi>
if i do i get the response
curl --request POST \
--url <http://localhost:4466/check> \
--header 'Content-Type: application/json' \
--data '	{
"namespace": "ukama",
"object": "billing",
"relation": "owner",
"subject_id": "user"
}'
s
The latest version of the client is v0.11.0-alpha.0, same as that is the latest server version, please use those
f
I have downgraded to that version but facing same issue.It is using a wrong url is there a way to config the check permission url @steep-lamp-91158 It goes to this url /relation-tuples/check/openapi?namespace instead if http://localhost:4466/check
s
are you using the code from above? I am not sure you can mutate the config and reuse it after it is created like you did there
but the correct url is
/relation-tuples/check/openapi
what is your server version? client and server versions have to match
f
@steep-lamp-91158 Am using Keto version: v0.6.0-alpha.1 and sdk v0.11.0-alpha.0
m
@flat-rose-25983 In that case either use the Keto version https://github.com/ory/keto/releases/tag/v0.11.1-alpha.0 and sdk v0.11.0-alpha.0 or Keto version: v0.6.0-alpha.1 and https://github.com/ory/keto-client-go/releases/tag/v0.6.0-alpha.1 the SDK and Keto version have to be the same!