ory / sdk

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

Not getting session info #286

Open nihalgurjar47 opened 1 year ago

nihalgurjar47 commented 1 year ago

Preflight checklist

Ory Network Project

No response

Describe the bug

def user_kratos_session_info():

Enter a context with an instance of the API client

kratos_url = "http://localhost:4433"
with ory_kratos_client.ApiClient(configuration=kratos_url) as api_client:
    api_instance = frontend_api.FrontendApi(api_client)
    cookie = "csrf_token_806060ca5bf70dff3caa0e5c860002aade9d470a5a4dce73bcfa7ba10778f481=564ihowvLVIqiCqjb1oH2U1O3y8vd1exNJdq0fEym+M="
    try:
        api_response = api_instance.to_session(cookie=f"ory_session={cookie}")
        print("session_api", api_response)
    except ory_kratos_client.ApiException as e:
        print("Exception when calling FrontendApi->to_session: %s")

user_kratos_session_info()

I am calling this Python function to retrieve the session info, but I am encountering a 401 (unauthorized) error. I am passing the exact cookies that were generated at the same time.

Reproducing the bug

Kratos run through the docker-compose.

kratos_url = "http://localhost:4433"

Relevant log output

No response

Relevant configuration

No response

Version

ory-kratos-client==0.13.1

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Docker Compose

Additional Context

Once the user is logged in, we aim to retrieve session information for the active user. However, I am unable to obtain the session information using the Python SDK.

vinckr commented 1 year ago

Hello @nihalgurjar47

Are you positive the cookie is passed in the request? can you maybe try the request through curl and see if it succeeds?

See also this doc: https://www.ory.sh/docs/troubleshooting/csrf