bright-policeman-41717
01/09/2023, 8:12 AMpackage main
import (
"context"
"fmt"
ory "<http://github.com/ory/client-go|github.com/ory/client-go>"
)
var client = NewSDK()
// Use this context to access Ory APIs which require an Ory API key.
var oryAuthedContext = context.WithValue(context.Background(), ory.ContextAccessToken, "ory_pat_vvvvvvv")
func NewSDK() *ory.APIClient {
conf := ory.NewConfiguration()
conf.Servers = ory.ServerConfigurations{{
URL: "<https://vvvvvvv.projects.oryapis.com/>",
}}
return ory.NewAPIClient(conf)
}
func main() {
identity, res, err := client.IdentityApi.CreateIdentity(oryAuthedContext).CreateIdentityBody(ory.CreateIdentityBody{
SchemaId: "default",
Traits: map[string]interface{}{
"email": "<mailto:hello@example.org|hello@example.org>",
},
}).Execute()
if err != nil {
panic(err)
}
fmt.Println(identity.Id, res.StatusCode)
}
proud-plumber-24205
01/09/2023, 9:32 AMproud-plumber-24205
01/09/2023, 9:46 AM$ ory list projects
$ ory get project <id> --format json | jq | grep default_schema_id
wonderful-lamp-2357
01/09/2023, 10:16 AMbright-policeman-41717
01/09/2023, 11:01 AMidentity, res, err := client.IdentityApi.CreateIdentity(oryAuthedContext).CreateIdentityBody(ory.CreateIdentityBody{
SchemaId: "<preset://email>",
Traits: map[string]interface{}{
"email": "<mailto:vvvvv@gmail.com|vvvvv@gmail.com>",
},
}).Execute()
if err != nil {
log.Println(err.Error())
}
bright-policeman-41717
01/09/2023, 11:02 AMadorable-bird-44969
01/09/2023, 11:22 AMproud-plumber-24205
01/09/2023, 11:22 AMproud-plumber-24205
01/09/2023, 11:22 AMproud-plumber-24205
01/09/2023, 11:22 AMfunc NewSDK() *ory.APIClient {
conf := ory.NewConfiguration()
conf.Servers = ory.ServerConfigurations{{
URL: "https://.<http://projects.oryapis.com|projects.oryapis.com>", <-- removed /
}}
return ory.NewAPIClient(conf)
}
bright-policeman-41717
01/09/2023, 11:27 AM