ory / ory/sdk

Rust SDK does not set ACCEPT header

Open
#301 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
PHP
Stars
178
Forks
96
Avg merge
6d 23h
Merged PRs (30d)
3

Description

Preflight checklist
Ory Network Project

No response

Describe the bug

When using kratos-client-rust in WASM, the ACCEPT header is set to */* for all requests, resulting in 303 redirect requests on browser flow endpoints.

It is unclear if this is as a result of a lack of functionality in openapi-generator or if the custom Ory templates do not include the necessary lines as the header is set in other SDKs.

This could also be by design, however there is no way to set the ACCEPT header meaning the browsers tested will automatically follow the 303 response in the AJAX request, and other SDKs such as Go do explicitly set this to application/json.

Reproducing the bug
  1. Setup self hosted kratos
  2. call ory_kratos_client::apis::frontend_api::create_browser_login_flow from a rust project, specifically WASM
  3. Observe a XHR request with Accept: */*
  4. Receive a 303 response redirecting to the login UI as if directly accessed from the browser instead of the expected 200 with JSON response.
Relevant log output

No response

Relevant configuration

No response

Version

1.0.0

On which operating system are you observing this issue?

Other

In which environment are you deploying?

Other

Additional Context

Running in a Yew v0.21.0 Rust WASM app bundled with Trunk v0.17.5.

Tested against Kratos 1.0.0 in Chrome 118.0.5993.117 and Safari 17.0 on macOS, however the line parameters are missing from the generated rust sources meaning it could be undefined behavior.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated Rust source for ory_kratos_client::apis::frontend_api::create_browser_login_flow and compare its request headers with the Go SDK, checking whether the openapi-generator or custom templates are responsible. Done means WASM requests send Accept: application/json and browser login flow calls receive the expected JSON response rather than a 303 redirect.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, wasm
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.