ory / sdk

The place where ORY's SDKs are being auto-generated
Apache License 2.0
137 stars 85 forks source link

[Go] Cannot get Identity results after Register with Kratos SDK v1.0.0 #292

Closed bcordobaq closed 3 weeks ago

bcordobaq commented 10 months ago

Preflight checklist

Ory Network Project

No response

Describe the bug

Implementing the register identity method with the Ory Kratos SDK (kratos-client-go) v1.0.0, I noticed that the SDK is not returning the result object with the created identity. However, the identity is correctly processed and it's mapped in the response object. With kratos-client-go v0.13.0 it works well.

Reproducing the bug

having this snippet of go code to register, using github.com/ory/kratos-client-go v1.0.0:

package main

import (
    "context"
    "fmt"
    "log"
    "net/http/httputil"

    kratos "github.com/ory/kratos-client-go"
)

func main() {
    client := kratos.NewAPIClient(
        &kratos.Configuration{
            Servers: kratos.ServerConfigurations{
                {
                    URL: "http://localhost:4433",
                },
            },
        })

    ctx := context.Background()

    // Initialize the flow
    flow, _, err := client.FrontendApi.CreateNativeRegistrationFlow(ctx).Execute()
    if err != nil {
        log.Fatal("cannot init register flow: ", err)
    }

    // Submit the registration flow
    result, resp, err := client.FrontendApi.UpdateRegistrationFlow(ctx).Flow(flow.Id).UpdateRegistrationFlowBody(
        kratos.UpdateRegistrationFlowBody{
            UpdateRegistrationFlowWithPasswordMethod: &kratos.UpdateRegistrationFlowWithPasswordMethod{
                Method:   "password",
                Password: "<your-password>",
                Traits:   map[string]interface{}{"email": "test@test.com"},
            }}).Execute()
    if err != nil {
        log.Fatal("cannot register identity: ", err)
    }

    fmt.Printf("identity result: %+v\n", result)
    respData, _ := httputil.DumpResponse(resp, true)
    fmt.Println(string(respData))
}

Relevant log output

identity result: &{ContinueWith:[] Identity:{CreatedAt:<nil> Credentials:<nil> Id: MetadataAdmin:<nil> MetadataPublic:<nil> RecoveryAddresses:[] SchemaId: SchemaUrl: State:<nil> StateChangedAt:<nil> Traits:<nil> UpdatedAt:<nil> VerifiableAddresses:[] AdditionalProperties:map[]} Session:<nil> SessionToken:<nil> AdditionalProperties:map[]}

HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Mon, 11 Sep 2023 02:57:53 GMT
Vary: Cookie

945
{"session_token":"ory_st_9HhKxmrgAF1GP57VAynBW7BMTT4jutxB","session":{"id":"2d50d4db-b645-4819-8bff-73fb3ffc56a5","active":true,"expires_at":"2023-09-12T02:57:53.688934128Z","authenticated_at":"2023-09-11T02:57:53.69437967Z","authenticator_assurance_level":"aal1","authentication_methods":[{"method":"password","aal":"aal1","completed_at":"2023-09-11T02:57:53.688933753Z"}],"issued_at":"2023-09-11T02:57:53.688934128Z","identity":{"id":"4e3b29a1-b9cf-4baa-98ad-f8d51d430ea8","schema_id":"default","schema_url":"http://localhost:4433/schemas/ZWNseXBzaXVt","state":"active","state_changed_at":"2023-09-11T02:57:53.682665378Z","traits":{"email":"test@test.com"},"verifiable_addresses":[{"id":"a947fe0f-6c83-45dd-8dae-442a0bdd267d","value":"test@test.com","verified":false,"via":"email","status":"sent","created_at":"2023-09-11T02:57:53.685776Z","updated_at":"2023-09-11T02:57:53.685776Z"}],"recovery_addresses":[{"id":"1b97a3a1-7f2e-495d-bb39-750c9399eb09","value":"test@test.com","via":"email","created_at":"2023-09-11T02:57:53.686579Z","updated_at":"2023-09-11T02:57:53.686579Z"}],"metadata_public":null,"created_at":"2023-09-11T02:57:53.685295Z","updated_at":"2023-09-11T02:57:53.685295Z"},"devices":[{"id":"1e575e28-3f4f-41d5-aec0-0bf812ac007e","ip_address":"172.23.0.1:57696","user_agent":null,"location":""}]},"identity":{"id":"4e3b29a1-b9cf-4baa-98ad-f8d51d430ea8","schema_id":"default","schema_url":"http://localhost:4433/schemas/ZWNseXBzaXVt","state":"active","state_changed_at":"2023-09-11T02:57:53.682665378Z","traits":{"email":"test@test.com"},"verifiable_addresses":[{"id":"a947fe0f-6c83-45dd-8dae-442a0bdd267d","value":"test@test.com","verified":false,"via":"email","status":"sent","created_at":"2023-09-11T02:57:53.685776Z","updated_at":"2023-09-11T02:57:53.685776Z"}],"recovery_addresses":[{"id":"1b97a3a1-7f2e-495d-bb39-750c9399eb09","value":"test@test.com","via":"email","created_at":"2023-09-11T02:57:53.686579Z","updated_at":"2023-09-11T02:57:53.686579Z"}],"metadata_public":null,"created_at":"2023-09-11T02:57:53.685295Z","updated_at":"2023-09-11T02:57:53.685295Z"},"continue_with":[{"action":"show_verification_ui","flow":{"id":"e207243e-e07b-48f6-9198-ea8f5dc93979","verifiable_address":"test@test.com"}},{"action":"set_ory_session_token","ory_session_token":"ory_st_9HhKxmrgAF1GP57VAynBW7BMTT4jutxB"}]}

0

Relevant configuration

No response

Version

v1.0.0

On which operating system are you observing this issue?

None

In which environment are you deploying?

Docker Compose

Additional Context

No response

bcordobaq commented 9 months ago

@aeneasr any updates on this?

aeneasr commented 3 weeks ago

This should be fixed in recent versions!