I'm get a panic when trying to list all projects using an Org API Key. This works with an environment scoped API Key.
package main
import (
"context"
"fmt"
"github.com/permitio/permit-golang/pkg/config"
"github.com/permitio/permit-golang/pkg/permit"
"go.uber.org/zap"
)
func main() {
// This line initializes the SDK and connects your Go app
// to the Permit.io PDP container (you've set in the previous step), with the API key provided.
permitClient := permit.NewPermit(
// Building new config for Permit client
config.NewConfigBuilder(
// your api key "***").
// Set the PDP URL
WithLogger(zap.NewExample()).
WithPdpUrl("http://localhost:7766").
Build(),
)
ctx := context.TODO()
projects, _ := permitClient.Api.Projects.List(ctx, 1, 10)
for i := 0; i < len(projects); i++ {
fmt.Println(projects[i].Name)
}
}
I was able to work through these panics, but then get this error
{"level":"error","msg":"","error":"ErrorCode: ContextError ErrorType:general_error Message:The context is missing or invalid - You're trying to use an SDK method that's specific to a project,but you haven't set the current project in your client's context yet,or you are using an organization level API key.Please set the context to a specificproject using `PermitClient.SetPermitContext()` method."}
I'm get a panic when trying to list all projects using an Org API Key. This works with an environment scoped API Key.
However, I get this panic
I was able to work through these panics, but then get this error