planetscale-go
planetscale-go copied to clipboard
service-token to create branch
I have created a service token to create a new branch but I am getting "not found" when I use it. Same code is working with access token.
Hi @cemo
Could you provide step-by-step instructions on what exactly you did (such as which commands you used to create the token) and the command you use, where you get the not found error?
Hi @fatih,
package main
import (
"context"
"fmt"
"github.com/planetscale/planetscale-go/planetscale"
)
func main() {
ctx := context.Background()
// create a new PlanetScale API client with the given access token
client, _ := planetscale.NewClient(
planetscale.WithServiceToken("tok", "***"),
)
//client, _ := planetscale.NewClient(
// planetscale.WithAccessToken("***"),
//)
// list all databases for the given organization
databases, _ := client.Databases.List(ctx, &planetscale.ListDatabasesRequest{
Organization: "startupheroes",
})
fmt.Printf("Found %d databases\n", len(databases))
for _, db := range databases {
fmt.Printf("Name: %q\n", db.Name)
fmt.Printf("Notes: %q\n", db.Notes)
}
}
Here is a sample. service-token based client can not return databases.
I created my service token via UI but auth token by CLI. I added all permissions to my token at UI by the way.
I am not sure but It seems service-token approach is totally broken.