Skip to main content

ory_client/apis/
frontend_api.rs

1/*
2 * Ory APIs
3 *
4 * # Introduction Documentation for all public and administrative Ory APIs. Administrative APIs can only be accessed with a valid Personal Access Token. Public APIs are mostly used in browsers.  ## SDKs This document describes the APIs available in the Ory Network. The APIs are available as SDKs for the following languages:  | Language       | Download SDK                                                     | Documentation                                                                        | | -------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | Dart           | [pub.dev](https://pub.dev/packages/ory_client)                   | [README](https://github.com/ory/sdk/blob/master/clients/client/dart/README.md)       | | .NET           | [nuget.org](https://www.nuget.org/packages/Ory.Client/)          | [README](https://github.com/ory/sdk/blob/master/clients/client/dotnet/README.md)     | | Elixir         | [hex.pm](https://hex.pm/packages/ory_client)                     | [README](https://github.com/ory/sdk/blob/master/clients/client/elixir/README.md)     | | Go             | [github.com](https://github.com/ory/client-go)                   | [README](https://github.com/ory/sdk/blob/master/clients/client/go/README.md)         | | Java           | [maven.org](https://search.maven.org/artifact/sh.ory/ory-client) | [README](https://github.com/ory/sdk/blob/master/clients/client/java/README.md)       | | JavaScript     | [npmjs.com](https://www.npmjs.com/package/@ory/client)           | [README](https://github.com/ory/sdk/blob/master/clients/client/typescript/README.md) | | JavaScript (With fetch) | [npmjs.com](https://www.npmjs.com/package/@ory/client-fetch)           | [README](https://github.com/ory/sdk/blob/master/clients/client/typescript-fetch/README.md) |  | PHP            | [packagist.org](https://packagist.org/packages/ory/client)       | [README](https://github.com/ory/sdk/blob/master/clients/client/php/README.md)        | | Python         | [pypi.org](https://pypi.org/project/ory-client/)                 | [README](https://github.com/ory/sdk/blob/master/clients/client/python/README.md)     | | Ruby           | [rubygems.org](https://rubygems.org/gems/ory-client)             | [README](https://github.com/ory/sdk/blob/master/clients/client/ruby/README.md)       | | Rust           | [crates.io](https://crates.io/crates/ory-client)                 | [README](https://github.com/ory/sdk/blob/master/clients/client/rust/README.md)       | 
5 *
6 * The version of the OpenAPI document: v1.22.78
7 * Contact: support@ory.sh
8 * Generated by: https://openapi-generator.tech
9 */
10
11
12use reqwest;
13use serde::{Deserialize, Serialize, de::Error as _};
14use crate::{apis::ResponseContent, models};
15use super::{Error, configuration, ContentType};
16
17
18/// struct for typed errors of method [`create_browser_login_flow`]
19#[derive(Debug, Clone, Serialize, Deserialize)]
20#[serde(untagged)]
21pub enum CreateBrowserLoginFlowError {
22    Status400(models::ErrorGeneric),
23    Status403(models::ErrorGeneric),
24    DefaultResponse(models::ErrorGeneric),
25    UnknownValue(serde_json::Value),
26}
27
28/// struct for typed errors of method [`create_browser_logout_flow`]
29#[derive(Debug, Clone, Serialize, Deserialize)]
30#[serde(untagged)]
31pub enum CreateBrowserLogoutFlowError {
32    Status400(models::ErrorGeneric),
33    Status401(models::ErrorGeneric),
34    Status500(models::ErrorGeneric),
35    UnknownValue(serde_json::Value),
36}
37
38/// struct for typed errors of method [`create_browser_recovery_flow`]
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(untagged)]
41pub enum CreateBrowserRecoveryFlowError {
42    Status400(models::ErrorGeneric),
43    DefaultResponse(models::ErrorGeneric),
44    UnknownValue(serde_json::Value),
45}
46
47/// struct for typed errors of method [`create_browser_registration_flow`]
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(untagged)]
50pub enum CreateBrowserRegistrationFlowError {
51    DefaultResponse(models::ErrorGeneric),
52    UnknownValue(serde_json::Value),
53}
54
55/// struct for typed errors of method [`create_browser_settings_flow`]
56#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(untagged)]
58pub enum CreateBrowserSettingsFlowError {
59    Status400(models::ErrorGeneric),
60    Status401(models::ErrorGeneric),
61    Status403(models::ErrorGeneric),
62    DefaultResponse(models::ErrorGeneric),
63    UnknownValue(serde_json::Value),
64}
65
66/// struct for typed errors of method [`create_browser_verification_flow`]
67#[derive(Debug, Clone, Serialize, Deserialize)]
68#[serde(untagged)]
69pub enum CreateBrowserVerificationFlowError {
70    DefaultResponse(models::ErrorGeneric),
71    UnknownValue(serde_json::Value),
72}
73
74/// struct for typed errors of method [`create_fedcm_flow`]
75#[derive(Debug, Clone, Serialize, Deserialize)]
76#[serde(untagged)]
77pub enum CreateFedcmFlowError {
78    Status400(models::ErrorGeneric),
79    DefaultResponse(models::ErrorGeneric),
80    UnknownValue(serde_json::Value),
81}
82
83/// struct for typed errors of method [`create_id_p_initiated_saml_browser_login_flow`]
84#[derive(Debug, Clone, Serialize, Deserialize)]
85#[serde(untagged)]
86pub enum CreateIdPInitiatedSamlBrowserLoginFlowError {
87    DefaultResponse(models::ErrorGeneric),
88    UnknownValue(serde_json::Value),
89}
90
91/// struct for typed errors of method [`create_native_login_flow`]
92#[derive(Debug, Clone, Serialize, Deserialize)]
93#[serde(untagged)]
94pub enum CreateNativeLoginFlowError {
95    Status400(models::ErrorGeneric),
96    Status403(models::ErrorGeneric),
97    DefaultResponse(models::ErrorGeneric),
98    UnknownValue(serde_json::Value),
99}
100
101/// struct for typed errors of method [`create_native_recovery_flow`]
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(untagged)]
104pub enum CreateNativeRecoveryFlowError {
105    Status400(models::ErrorGeneric),
106    DefaultResponse(models::ErrorGeneric),
107    UnknownValue(serde_json::Value),
108}
109
110/// struct for typed errors of method [`create_native_registration_flow`]
111#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(untagged)]
113pub enum CreateNativeRegistrationFlowError {
114    Status400(models::ErrorGeneric),
115    DefaultResponse(models::ErrorGeneric),
116    UnknownValue(serde_json::Value),
117}
118
119/// struct for typed errors of method [`create_native_settings_flow`]
120#[derive(Debug, Clone, Serialize, Deserialize)]
121#[serde(untagged)]
122pub enum CreateNativeSettingsFlowError {
123    Status400(models::ErrorGeneric),
124    DefaultResponse(models::ErrorGeneric),
125    UnknownValue(serde_json::Value),
126}
127
128/// struct for typed errors of method [`create_native_verification_flow`]
129#[derive(Debug, Clone, Serialize, Deserialize)]
130#[serde(untagged)]
131pub enum CreateNativeVerificationFlowError {
132    Status400(models::ErrorGeneric),
133    DefaultResponse(models::ErrorGeneric),
134    UnknownValue(serde_json::Value),
135}
136
137/// struct for typed errors of method [`delete_test_login_flow`]
138#[derive(Debug, Clone, Serialize, Deserialize)]
139#[serde(untagged)]
140pub enum DeleteTestLoginFlowError {
141    Status400(models::ErrorGeneric),
142    Status403(models::ErrorGeneric),
143    Status404(models::ErrorGeneric),
144    DefaultResponse(models::ErrorGeneric),
145    UnknownValue(serde_json::Value),
146}
147
148/// struct for typed errors of method [`disable_my_other_sessions`]
149#[derive(Debug, Clone, Serialize, Deserialize)]
150#[serde(untagged)]
151pub enum DisableMyOtherSessionsError {
152    Status400(models::ErrorGeneric),
153    Status401(models::ErrorGeneric),
154    DefaultResponse(models::ErrorGeneric),
155    UnknownValue(serde_json::Value),
156}
157
158/// struct for typed errors of method [`disable_my_session`]
159#[derive(Debug, Clone, Serialize, Deserialize)]
160#[serde(untagged)]
161pub enum DisableMySessionError {
162    Status400(models::ErrorGeneric),
163    Status401(models::ErrorGeneric),
164    DefaultResponse(models::ErrorGeneric),
165    UnknownValue(serde_json::Value),
166}
167
168/// struct for typed errors of method [`exchange_session_token`]
169#[derive(Debug, Clone, Serialize, Deserialize)]
170#[serde(untagged)]
171pub enum ExchangeSessionTokenError {
172    Status403(models::ErrorGeneric),
173    Status404(models::ErrorGeneric),
174    Status410(models::ErrorGeneric),
175    Status422(models::ErrorGeneric),
176    DefaultResponse(models::ErrorGeneric),
177    UnknownValue(serde_json::Value),
178}
179
180/// struct for typed errors of method [`get_flow_error`]
181#[derive(Debug, Clone, Serialize, Deserialize)]
182#[serde(untagged)]
183pub enum GetFlowErrorError {
184    Status403(models::ErrorGeneric),
185    Status404(models::ErrorGeneric),
186    Status500(models::ErrorGeneric),
187    UnknownValue(serde_json::Value),
188}
189
190/// struct for typed errors of method [`get_login_flow`]
191#[derive(Debug, Clone, Serialize, Deserialize)]
192#[serde(untagged)]
193pub enum GetLoginFlowError {
194    Status403(models::ErrorGeneric),
195    Status404(models::ErrorGeneric),
196    Status410(models::ErrorGeneric),
197    DefaultResponse(models::ErrorGeneric),
198    UnknownValue(serde_json::Value),
199}
200
201/// struct for typed errors of method [`get_recovery_flow`]
202#[derive(Debug, Clone, Serialize, Deserialize)]
203#[serde(untagged)]
204pub enum GetRecoveryFlowError {
205    Status404(models::ErrorGeneric),
206    Status410(models::ErrorGeneric),
207    DefaultResponse(models::ErrorGeneric),
208    UnknownValue(serde_json::Value),
209}
210
211/// struct for typed errors of method [`get_registration_flow`]
212#[derive(Debug, Clone, Serialize, Deserialize)]
213#[serde(untagged)]
214pub enum GetRegistrationFlowError {
215    Status403(models::ErrorGeneric),
216    Status404(models::ErrorGeneric),
217    Status410(models::ErrorGeneric),
218    DefaultResponse(models::ErrorGeneric),
219    UnknownValue(serde_json::Value),
220}
221
222/// struct for typed errors of method [`get_settings_flow`]
223#[derive(Debug, Clone, Serialize, Deserialize)]
224#[serde(untagged)]
225pub enum GetSettingsFlowError {
226    Status401(models::ErrorGeneric),
227    Status403(models::ErrorGeneric),
228    Status404(models::ErrorGeneric),
229    Status410(models::ErrorGeneric),
230    DefaultResponse(models::ErrorGeneric),
231    UnknownValue(serde_json::Value),
232}
233
234/// struct for typed errors of method [`get_verification_flow`]
235#[derive(Debug, Clone, Serialize, Deserialize)]
236#[serde(untagged)]
237pub enum GetVerificationFlowError {
238    Status403(models::ErrorGeneric),
239    Status404(models::ErrorGeneric),
240    DefaultResponse(models::ErrorGeneric),
241    UnknownValue(serde_json::Value),
242}
243
244/// struct for typed errors of method [`get_web_authn_java_script`]
245#[derive(Debug, Clone, Serialize, Deserialize)]
246#[serde(untagged)]
247pub enum GetWebAuthnJavaScriptError {
248    UnknownValue(serde_json::Value),
249}
250
251/// struct for typed errors of method [`get_web_authn_related_origins`]
252#[derive(Debug, Clone, Serialize, Deserialize)]
253#[serde(untagged)]
254pub enum GetWebAuthnRelatedOriginsError {
255    UnknownValue(serde_json::Value),
256}
257
258/// struct for typed errors of method [`get_well_known_change_password`]
259#[derive(Debug, Clone, Serialize, Deserialize)]
260#[serde(untagged)]
261pub enum GetWellKnownChangePasswordError {
262    DefaultResponse(models::ErrorGeneric),
263    UnknownValue(serde_json::Value),
264}
265
266/// struct for typed errors of method [`list_my_sessions`]
267#[derive(Debug, Clone, Serialize, Deserialize)]
268#[serde(untagged)]
269pub enum ListMySessionsError {
270    Status400(models::ErrorGeneric),
271    Status401(models::ErrorGeneric),
272    Status403(models::ErrorGeneric),
273    DefaultResponse(models::ErrorGeneric),
274    UnknownValue(serde_json::Value),
275}
276
277/// struct for typed errors of method [`perform_native_logout`]
278#[derive(Debug, Clone, Serialize, Deserialize)]
279#[serde(untagged)]
280pub enum PerformNativeLogoutError {
281    Status400(models::ErrorGeneric),
282    DefaultResponse(models::ErrorGeneric),
283    UnknownValue(serde_json::Value),
284}
285
286/// struct for typed errors of method [`to_session`]
287#[derive(Debug, Clone, Serialize, Deserialize)]
288#[serde(untagged)]
289pub enum ToSessionError {
290    Status401(models::ErrorGeneric),
291    Status403(models::ErrorGeneric),
292    DefaultResponse(models::ErrorGeneric),
293    UnknownValue(serde_json::Value),
294}
295
296/// struct for typed errors of method [`update_fedcm_flow`]
297#[derive(Debug, Clone, Serialize, Deserialize)]
298#[serde(untagged)]
299pub enum UpdateFedcmFlowError {
300    Status400(models::LoginFlow),
301    Status410(models::ErrorGeneric),
302    Status422(models::ErrorBrowserLocationChangeRequired),
303    DefaultResponse(models::ErrorGeneric),
304    UnknownValue(serde_json::Value),
305}
306
307/// struct for typed errors of method [`update_login_flow`]
308#[derive(Debug, Clone, Serialize, Deserialize)]
309#[serde(untagged)]
310pub enum UpdateLoginFlowError {
311    Status400(models::LoginFlow),
312    Status410(models::ErrorGeneric),
313    Status422(models::ErrorBrowserLocationChangeRequired),
314    DefaultResponse(models::ErrorGeneric),
315    UnknownValue(serde_json::Value),
316}
317
318/// struct for typed errors of method [`update_logout_flow`]
319#[derive(Debug, Clone, Serialize, Deserialize)]
320#[serde(untagged)]
321pub enum UpdateLogoutFlowError {
322    DefaultResponse(models::ErrorGeneric),
323    UnknownValue(serde_json::Value),
324}
325
326/// struct for typed errors of method [`update_recovery_flow`]
327#[derive(Debug, Clone, Serialize, Deserialize)]
328#[serde(untagged)]
329pub enum UpdateRecoveryFlowError {
330    Status400(models::RecoveryFlow),
331    Status410(models::ErrorGeneric),
332    Status422(models::ErrorBrowserLocationChangeRequired),
333    DefaultResponse(models::ErrorGeneric),
334    UnknownValue(serde_json::Value),
335}
336
337/// struct for typed errors of method [`update_registration_flow`]
338#[derive(Debug, Clone, Serialize, Deserialize)]
339#[serde(untagged)]
340pub enum UpdateRegistrationFlowError {
341    Status400(models::RegistrationFlow),
342    Status410(models::ErrorGeneric),
343    Status422(models::ErrorBrowserLocationChangeRequired),
344    DefaultResponse(models::ErrorGeneric),
345    UnknownValue(serde_json::Value),
346}
347
348/// struct for typed errors of method [`update_settings_flow`]
349#[derive(Debug, Clone, Serialize, Deserialize)]
350#[serde(untagged)]
351pub enum UpdateSettingsFlowError {
352    Status400(models::SettingsFlow),
353    Status401(models::ErrorGeneric),
354    Status403(models::ErrorGeneric),
355    Status410(models::ErrorGeneric),
356    Status422(models::ErrorBrowserLocationChangeRequired),
357    DefaultResponse(models::ErrorGeneric),
358    UnknownValue(serde_json::Value),
359}
360
361/// struct for typed errors of method [`update_verification_flow`]
362#[derive(Debug, Clone, Serialize, Deserialize)]
363#[serde(untagged)]
364pub enum UpdateVerificationFlowError {
365    Status400(models::VerificationFlow),
366    Status410(models::ErrorGeneric),
367    DefaultResponse(models::ErrorGeneric),
368    UnknownValue(serde_json::Value),
369}
370
371
372/// This endpoint initializes a browser-based user login flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.login.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url` unless the query parameter `?refresh=true` was set.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  - `session_already_available`: The user is already signed in. - `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. - `session_aal2_enrollment_required`: Second-factor auth is required but the identity has no second factor enrolled. Follow `redirect_browser_to` to the settings flow to enroll one. - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. - `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  The optional query parameter login_challenge is set when using Kratos with Hydra in an OAuth2 flow. See the oauth2_provider.url configuration option.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Login](https://www.ory.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
373pub async fn create_browser_login_flow(configuration: &configuration::Configuration, refresh: Option<bool>, aal: Option<&str>, return_to: Option<&str>, cookie: Option<&str>, login_challenge: Option<&str>, organization: Option<&str>, via: Option<&str>, identity_schema: Option<&str>) -> Result<models::LoginFlow, Error<CreateBrowserLoginFlowError>> {
374    // add a prefix to parameters to efficiently prevent name collisions
375    let p_query_refresh = refresh;
376    let p_query_aal = aal;
377    let p_query_return_to = return_to;
378    let p_header_cookie = cookie;
379    let p_query_login_challenge = login_challenge;
380    let p_query_organization = organization;
381    let p_query_via = via;
382    let p_query_identity_schema = identity_schema;
383
384    let uri_str = format!("{}/self-service/login/browser", configuration.base_path);
385    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
386
387    if let Some(ref param_value) = p_query_refresh {
388        req_builder = req_builder.query(&[("refresh", &param_value.to_string())]);
389    }
390    if let Some(ref param_value) = p_query_aal {
391        req_builder = req_builder.query(&[("aal", &param_value.to_string())]);
392    }
393    if let Some(ref param_value) = p_query_return_to {
394        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
395    }
396    if let Some(ref param_value) = p_query_login_challenge {
397        req_builder = req_builder.query(&[("login_challenge", &param_value.to_string())]);
398    }
399    if let Some(ref param_value) = p_query_organization {
400        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
401    }
402    if let Some(ref param_value) = p_query_via {
403        req_builder = req_builder.query(&[("via", &param_value.to_string())]);
404    }
405    if let Some(ref param_value) = p_query_identity_schema {
406        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
407    }
408    if let Some(ref user_agent) = configuration.user_agent {
409        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
410    }
411    if let Some(param_value) = p_header_cookie {
412        req_builder = req_builder.header("Cookie", param_value.to_string());
413    }
414
415    let req = req_builder.build()?;
416    let resp = configuration.client.execute(req).await?;
417
418    let status = resp.status();
419    let content_type = resp
420        .headers()
421        .get("content-type")
422        .and_then(|v| v.to_str().ok())
423        .unwrap_or("application/octet-stream");
424    let content_type = super::ContentType::from(content_type);
425
426    if !status.is_client_error() && !status.is_server_error() {
427        let content = resp.text().await?;
428        match content_type {
429            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
430            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
431            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LoginFlow`")))),
432        }
433    } else {
434        let content = resp.text().await?;
435        let entity: Option<CreateBrowserLoginFlowError> = serde_json::from_str(&content).ok();
436        Err(Error::ResponseError(ResponseContent { status, content, entity }))
437    }
438}
439
440/// This endpoint initializes a browser-based user logout flow and a URL which can be used to log out the user.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token.  The URL is only valid for the currently signed in user. If no user is signed in, this endpoint returns a 401 error.  When calling this endpoint from a backend, please ensure to properly forward the HTTP cookies.
441pub async fn create_browser_logout_flow(configuration: &configuration::Configuration, cookie: Option<&str>, return_to: Option<&str>) -> Result<models::LogoutFlow, Error<CreateBrowserLogoutFlowError>> {
442    // add a prefix to parameters to efficiently prevent name collisions
443    let p_header_cookie = cookie;
444    let p_query_return_to = return_to;
445
446    let uri_str = format!("{}/self-service/logout/browser", configuration.base_path);
447    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
448
449    if let Some(ref param_value) = p_query_return_to {
450        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
451    }
452    if let Some(ref user_agent) = configuration.user_agent {
453        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
454    }
455    if let Some(param_value) = p_header_cookie {
456        req_builder = req_builder.header("cookie", param_value.to_string());
457    }
458
459    let req = req_builder.build()?;
460    let resp = configuration.client.execute(req).await?;
461
462    let status = resp.status();
463    let content_type = resp
464        .headers()
465        .get("content-type")
466        .and_then(|v| v.to_str().ok())
467        .unwrap_or("application/octet-stream");
468    let content_type = super::ContentType::from(content_type);
469
470    if !status.is_client_error() && !status.is_server_error() {
471        let content = resp.text().await?;
472        match content_type {
473            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
474            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LogoutFlow`"))),
475            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LogoutFlow`")))),
476        }
477    } else {
478        let content = resp.text().await?;
479        let entity: Option<CreateBrowserLogoutFlowError> = serde_json::from_str(&content).ok();
480        Err(Error::ResponseError(ResponseContent { status, content, entity }))
481    }
482}
483
484/// This endpoint initializes a browser-based account recovery flow. Once initialized, the browser will be redirected to `selfservice.flows.recovery.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists, the browser is returned to the configured return URL.  If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects or a 400 bad request error if the user is already authenticated.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
485pub async fn create_browser_recovery_flow(configuration: &configuration::Configuration, return_to: Option<&str>, skip_settings: Option<&str>) -> Result<models::RecoveryFlow, Error<CreateBrowserRecoveryFlowError>> {
486    // add a prefix to parameters to efficiently prevent name collisions
487    let p_query_return_to = return_to;
488    let p_query_skip_settings = skip_settings;
489
490    let uri_str = format!("{}/self-service/recovery/browser", configuration.base_path);
491    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
492
493    if let Some(ref param_value) = p_query_return_to {
494        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
495    }
496    if let Some(ref param_value) = p_query_skip_settings {
497        req_builder = req_builder.query(&[("skip_settings", &param_value.to_string())]);
498    }
499    if let Some(ref user_agent) = configuration.user_agent {
500        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
501    }
502
503    let req = req_builder.build()?;
504    let resp = configuration.client.execute(req).await?;
505
506    let status = resp.status();
507    let content_type = resp
508        .headers()
509        .get("content-type")
510        .and_then(|v| v.to_str().ok())
511        .unwrap_or("application/octet-stream");
512    let content_type = super::ContentType::from(content_type);
513
514    if !status.is_client_error() && !status.is_server_error() {
515        let content = resp.text().await?;
516        match content_type {
517            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
518            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
519            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RecoveryFlow`")))),
520        }
521    } else {
522        let content = resp.text().await?;
523        let entity: Option<CreateBrowserRecoveryFlowError> = serde_json::from_str(&content).ok();
524        Err(Error::ResponseError(ResponseContent { status, content, entity }))
525    }
526}
527
528/// This endpoint initializes a browser-based user registration flow. This endpoint will set the appropriate cookies and anti-CSRF measures required for browser-based flows.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.registration.ui_url` with the flow ID set as the query parameter `?flow=`. If a valid user session exists already, the browser will be redirected to `urls.default_redirect_url`.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  - `session_already_available`: The user is already signed in. - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. - `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  If this endpoint is called via an AJAX request, the response contains the registration flow without a redirect.  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Login](https://www.ory.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
529pub async fn create_browser_registration_flow(configuration: &configuration::Configuration, return_to: Option<&str>, login_challenge: Option<&str>, after_verification_return_to: Option<&str>, organization: Option<&str>, identity_schema: Option<&str>) -> Result<models::RegistrationFlow, Error<CreateBrowserRegistrationFlowError>> {
530    // add a prefix to parameters to efficiently prevent name collisions
531    let p_query_return_to = return_to;
532    let p_query_login_challenge = login_challenge;
533    let p_query_after_verification_return_to = after_verification_return_to;
534    let p_query_organization = organization;
535    let p_query_identity_schema = identity_schema;
536
537    let uri_str = format!("{}/self-service/registration/browser", configuration.base_path);
538    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
539
540    if let Some(ref param_value) = p_query_return_to {
541        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
542    }
543    if let Some(ref param_value) = p_query_login_challenge {
544        req_builder = req_builder.query(&[("login_challenge", &param_value.to_string())]);
545    }
546    if let Some(ref param_value) = p_query_after_verification_return_to {
547        req_builder = req_builder.query(&[("after_verification_return_to", &param_value.to_string())]);
548    }
549    if let Some(ref param_value) = p_query_organization {
550        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
551    }
552    if let Some(ref param_value) = p_query_identity_schema {
553        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
554    }
555    if let Some(ref user_agent) = configuration.user_agent {
556        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
557    }
558
559    let req = req_builder.build()?;
560    let resp = configuration.client.execute(req).await?;
561
562    let status = resp.status();
563    let content_type = resp
564        .headers()
565        .get("content-type")
566        .and_then(|v| v.to_str().ok())
567        .unwrap_or("application/octet-stream");
568    let content_type = super::ContentType::from(content_type);
569
570    if !status.is_client_error() && !status.is_server_error() {
571        let content = resp.text().await?;
572        match content_type {
573            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
574            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
575            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegistrationFlow`")))),
576        }
577    } else {
578        let content = resp.text().await?;
579        let entity: Option<CreateBrowserRegistrationFlowError> = serde_json::from_str(&content).ok();
580        Err(Error::ResponseError(ResponseContent { status, content, entity }))
581    }
582}
583
584/// This endpoint initializes a browser-based user settings flow. Once initialized, the browser will be redirected to `selfservice.flows.settings.ui_url` with the flow ID set as the query parameter `?flow=`. If no valid Ory Kratos Session Cookie is included in the request, a login flow will be initialized.  If this endpoint is opened as a link in the browser, it will be redirected to `selfservice.flows.settings.ui_url` with the flow ID set as the query parameter `?flow=`. If no valid user session was set, the browser will be redirected to the login endpoint.  If this endpoint is called via an AJAX request, the response contains the settings flow without any redirects or a 401 forbidden error if no valid session was set.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor (happens automatically for server-side browser flows) or change the configuration.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. - `session_inactive`: No Ory Session was found - sign in a user first. - `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration!  This endpoint is NOT INTENDED for clients that do not have a browser (Chrome, Firefox, ...) as cookies are needed.  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
585pub async fn create_browser_settings_flow(configuration: &configuration::Configuration, return_to: Option<&str>, cookie: Option<&str>, organization: Option<&str>) -> Result<models::SettingsFlow, Error<CreateBrowserSettingsFlowError>> {
586    // add a prefix to parameters to efficiently prevent name collisions
587    let p_query_return_to = return_to;
588    let p_header_cookie = cookie;
589    let p_query_organization = organization;
590
591    let uri_str = format!("{}/self-service/settings/browser", configuration.base_path);
592    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
593
594    if let Some(ref param_value) = p_query_return_to {
595        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
596    }
597    if let Some(ref param_value) = p_query_organization {
598        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
599    }
600    if let Some(ref user_agent) = configuration.user_agent {
601        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
602    }
603    if let Some(param_value) = p_header_cookie {
604        req_builder = req_builder.header("Cookie", param_value.to_string());
605    }
606
607    let req = req_builder.build()?;
608    let resp = configuration.client.execute(req).await?;
609
610    let status = resp.status();
611    let content_type = resp
612        .headers()
613        .get("content-type")
614        .and_then(|v| v.to_str().ok())
615        .unwrap_or("application/octet-stream");
616    let content_type = super::ContentType::from(content_type);
617
618    if !status.is_client_error() && !status.is_server_error() {
619        let content = resp.text().await?;
620        match content_type {
621            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
622            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
623            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SettingsFlow`")))),
624        }
625    } else {
626        let content = resp.text().await?;
627        let entity: Option<CreateBrowserSettingsFlowError> = serde_json::from_str(&content).ok();
628        Err(Error::ResponseError(ResponseContent { status, content, entity }))
629    }
630}
631
632/// This endpoint initializes a browser-based account verification flow. Once initialized, the browser will be redirected to `selfservice.flows.verification.ui_url` with the flow ID set as the query parameter `?flow=`.  If this endpoint is called via an AJAX request, the response contains the recovery flow without any redirects.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...).  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.com/docs/kratos/self-service/flows/verify-email-account-activation).
633pub async fn create_browser_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateBrowserVerificationFlowError>> {
634    // add a prefix to parameters to efficiently prevent name collisions
635    let p_query_return_to = return_to;
636
637    let uri_str = format!("{}/self-service/verification/browser", configuration.base_path);
638    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
639
640    if let Some(ref param_value) = p_query_return_to {
641        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
642    }
643    if let Some(ref user_agent) = configuration.user_agent {
644        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
645    }
646
647    let req = req_builder.build()?;
648    let resp = configuration.client.execute(req).await?;
649
650    let status = resp.status();
651    let content_type = resp
652        .headers()
653        .get("content-type")
654        .and_then(|v| v.to_str().ok())
655        .unwrap_or("application/octet-stream");
656    let content_type = super::ContentType::from(content_type);
657
658    if !status.is_client_error() && !status.is_server_error() {
659        let content = resp.text().await?;
660        match content_type {
661            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
662            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
663            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerificationFlow`")))),
664        }
665    } else {
666        let content = resp.text().await?;
667        let entity: Option<CreateBrowserVerificationFlowError> = serde_json::from_str(&content).ok();
668        Err(Error::ResponseError(ResponseContent { status, content, entity }))
669    }
670}
671
672/// This endpoint returns a list of all available FedCM providers. It is only supported on the Ory Network.
673pub async fn create_fedcm_flow(configuration: &configuration::Configuration, ) -> Result<models::CreateFedcmFlowResponse, Error<CreateFedcmFlowError>> {
674
675    let uri_str = format!("{}/self-service/fed-cm/parameters", configuration.base_path);
676    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
677
678    if let Some(ref user_agent) = configuration.user_agent {
679        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
680    }
681
682    let req = req_builder.build()?;
683    let resp = configuration.client.execute(req).await?;
684
685    let status = resp.status();
686    let content_type = resp
687        .headers()
688        .get("content-type")
689        .and_then(|v| v.to_str().ok())
690        .unwrap_or("application/octet-stream");
691    let content_type = super::ContentType::from(content_type);
692
693    if !status.is_client_error() && !status.is_server_error() {
694        let content = resp.text().await?;
695        match content_type {
696            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
697            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::CreateFedcmFlowResponse`"))),
698            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::CreateFedcmFlowResponse`")))),
699        }
700    } else {
701        let content = resp.text().await?;
702        let entity: Option<CreateFedcmFlowError> = serde_json::from_str(&content).ok();
703        Err(Error::ResponseError(ResponseContent { status, content, entity }))
704    }
705}
706
707/// This endpoint is the entry point for IdP-initiated login through Ory Polis. Ory Polis redirects the browser here with a single-use authorization code after validating an unsolicited SAML response; Kratos then starts a regular browser login flow and forwards the code as a `code_hint` so Polis can complete the flow without a second round-trip to the identity provider.  The provider must be a `jackson` provider with `idp_initiated_login_enabled` set to `true` in its configuration.  This endpoint is NOT INTENDED for API clients and only works with browsers.
708pub async fn create_id_p_initiated_saml_browser_login_flow(configuration: &configuration::Configuration, provider: &str, code: &str) -> Result<models::ErrorGeneric, Error<CreateIdPInitiatedSamlBrowserLoginFlowError>> {
709    // add a prefix to parameters to efficiently prevent name collisions
710    let p_path_provider = provider;
711    let p_query_code = code;
712
713    let uri_str = format!("{}/self-service/methods/saml/idp-initiated/{provider}", configuration.base_path, provider=crate::apis::urlencode(p_path_provider));
714    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
715
716    req_builder = req_builder.query(&[("code", &p_query_code.to_string())]);
717    if let Some(ref user_agent) = configuration.user_agent {
718        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
719    }
720
721    let req = req_builder.build()?;
722    let resp = configuration.client.execute(req).await?;
723
724    let status = resp.status();
725    let content_type = resp
726        .headers()
727        .get("content-type")
728        .and_then(|v| v.to_str().ok())
729        .unwrap_or("application/octet-stream");
730    let content_type = super::ContentType::from(content_type);
731
732    if !status.is_client_error() && !status.is_server_error() {
733        let content = resp.text().await?;
734        match content_type {
735            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
736            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ErrorGeneric`"))),
737            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ErrorGeneric`")))),
738        }
739    } else {
740        let content = resp.text().await?;
741        let entity: Option<CreateIdPInitiatedSamlBrowserLoginFlowError> = serde_json::from_str(&content).ok();
742        Err(Error::ResponseError(ResponseContent { status, content, entity }))
743    }
744}
745
746/// This endpoint initiates a login flow for native apps that do not use a browser, such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error will be returned unless the URL query parameter `?refresh=true` is set.  To fetch an existing login flow call `/self-service/login/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks, including CSRF login attacks.  In the case of an error, the `error.id` of the JSON response body can be one of:  - `session_already_available`: The user is already signed in. - `session_aal1_required`: Multi-factor auth (e.g. 2fa) was requested but the user has no session yet. - `session_aal2_enrollment_required`: Second-factor auth is required but the identity has no second factor enrolled. Follow `redirect_browser_to` to the settings flow to enroll one. - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Login](https://www.ory.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
747pub async fn create_native_login_flow(configuration: &configuration::Configuration, refresh: Option<bool>, aal: Option<&str>, x_session_token: Option<&str>, return_session_token_exchange_code: Option<bool>, return_to: Option<&str>, organization: Option<&str>, via: Option<&str>, identity_schema: Option<&str>) -> Result<models::LoginFlow, Error<CreateNativeLoginFlowError>> {
748    // add a prefix to parameters to efficiently prevent name collisions
749    let p_query_refresh = refresh;
750    let p_query_aal = aal;
751    let p_header_x_session_token = x_session_token;
752    let p_query_return_session_token_exchange_code = return_session_token_exchange_code;
753    let p_query_return_to = return_to;
754    let p_query_organization = organization;
755    let p_query_via = via;
756    let p_query_identity_schema = identity_schema;
757
758    let uri_str = format!("{}/self-service/login/api", configuration.base_path);
759    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
760
761    if let Some(ref param_value) = p_query_refresh {
762        req_builder = req_builder.query(&[("refresh", &param_value.to_string())]);
763    }
764    if let Some(ref param_value) = p_query_aal {
765        req_builder = req_builder.query(&[("aal", &param_value.to_string())]);
766    }
767    if let Some(ref param_value) = p_query_return_session_token_exchange_code {
768        req_builder = req_builder.query(&[("return_session_token_exchange_code", &param_value.to_string())]);
769    }
770    if let Some(ref param_value) = p_query_return_to {
771        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
772    }
773    if let Some(ref param_value) = p_query_organization {
774        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
775    }
776    if let Some(ref param_value) = p_query_via {
777        req_builder = req_builder.query(&[("via", &param_value.to_string())]);
778    }
779    if let Some(ref param_value) = p_query_identity_schema {
780        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
781    }
782    if let Some(ref user_agent) = configuration.user_agent {
783        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
784    }
785    if let Some(param_value) = p_header_x_session_token {
786        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
787    }
788
789    let req = req_builder.build()?;
790    let resp = configuration.client.execute(req).await?;
791
792    let status = resp.status();
793    let content_type = resp
794        .headers()
795        .get("content-type")
796        .and_then(|v| v.to_str().ok())
797        .unwrap_or("application/octet-stream");
798    let content_type = super::ContentType::from(content_type);
799
800    if !status.is_client_error() && !status.is_server_error() {
801        let content = resp.text().await?;
802        match content_type {
803            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
804            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
805            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LoginFlow`")))),
806        }
807    } else {
808        let content = resp.text().await?;
809        let entity: Option<CreateNativeLoginFlowError> = serde_json::from_str(&content).ok();
810        Err(Error::ResponseError(ResponseContent { status, content, entity }))
811    }
812}
813
814/// This endpoint initiates a recovery flow for API clients such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error.  On an existing recovery flow, use the `getRecoveryFlow` API endpoint.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
815pub async fn create_native_recovery_flow(configuration: &configuration::Configuration, ) -> Result<models::RecoveryFlow, Error<CreateNativeRecoveryFlowError>> {
816
817    let uri_str = format!("{}/self-service/recovery/api", configuration.base_path);
818    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
819
820    if let Some(ref user_agent) = configuration.user_agent {
821        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
822    }
823
824    let req = req_builder.build()?;
825    let resp = configuration.client.execute(req).await?;
826
827    let status = resp.status();
828    let content_type = resp
829        .headers()
830        .get("content-type")
831        .and_then(|v| v.to_str().ok())
832        .unwrap_or("application/octet-stream");
833    let content_type = super::ContentType::from(content_type);
834
835    if !status.is_client_error() && !status.is_server_error() {
836        let content = resp.text().await?;
837        match content_type {
838            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
839            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
840            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RecoveryFlow`")))),
841        }
842    } else {
843        let content = resp.text().await?;
844        let entity: Option<CreateNativeRecoveryFlowError> = serde_json::from_str(&content).ok();
845        Err(Error::ResponseError(ResponseContent { status, content, entity }))
846    }
847}
848
849/// This endpoint initiates a registration flow for API clients such as mobile devices, smart TVs, and so on.  If a valid provided session cookie or session token is provided, a 400 Bad Request error will be returned unless the URL query parameter `?refresh=true` is set.  To fetch an existing registration flow call `/self-service/registration/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  In the case of an error, the `error.id` of the JSON response body can be one of:  - `session_already_available`: The user is already signed in. - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Login](https://www.ory.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
850pub async fn create_native_registration_flow(configuration: &configuration::Configuration, return_session_token_exchange_code: Option<bool>, return_to: Option<&str>, organization: Option<&str>, identity_schema: Option<&str>) -> Result<models::RegistrationFlow, Error<CreateNativeRegistrationFlowError>> {
851    // add a prefix to parameters to efficiently prevent name collisions
852    let p_query_return_session_token_exchange_code = return_session_token_exchange_code;
853    let p_query_return_to = return_to;
854    let p_query_organization = organization;
855    let p_query_identity_schema = identity_schema;
856
857    let uri_str = format!("{}/self-service/registration/api", configuration.base_path);
858    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
859
860    if let Some(ref param_value) = p_query_return_session_token_exchange_code {
861        req_builder = req_builder.query(&[("return_session_token_exchange_code", &param_value.to_string())]);
862    }
863    if let Some(ref param_value) = p_query_return_to {
864        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
865    }
866    if let Some(ref param_value) = p_query_organization {
867        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
868    }
869    if let Some(ref param_value) = p_query_identity_schema {
870        req_builder = req_builder.query(&[("identity_schema", &param_value.to_string())]);
871    }
872    if let Some(ref user_agent) = configuration.user_agent {
873        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
874    }
875
876    let req = req_builder.build()?;
877    let resp = configuration.client.execute(req).await?;
878
879    let status = resp.status();
880    let content_type = resp
881        .headers()
882        .get("content-type")
883        .and_then(|v| v.to_str().ok())
884        .unwrap_or("application/octet-stream");
885    let content_type = super::ContentType::from(content_type);
886
887    if !status.is_client_error() && !status.is_server_error() {
888        let content = resp.text().await?;
889        match content_type {
890            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
891            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
892            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegistrationFlow`")))),
893        }
894    } else {
895        let content = resp.text().await?;
896        let entity: Option<CreateNativeRegistrationFlowError> = serde_json::from_str(&content).ok();
897        Err(Error::ResponseError(ResponseContent { status, content, entity }))
898    }
899}
900
901/// This endpoint initiates a settings flow for API clients such as mobile devices, smart TVs, and so on. You must provide a valid Ory Kratos Session Token for this endpoint to respond with HTTP 200 OK.  To fetch an existing settings flow call `/self-service/settings/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.  In the case of an error, the `error.id` of the JSON response body can be one of:  - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. - `session_inactive`: No Ory Session was found - sign in a user first.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
902pub async fn create_native_settings_flow(configuration: &configuration::Configuration, x_session_token: Option<&str>, organization: Option<&str>) -> Result<models::SettingsFlow, Error<CreateNativeSettingsFlowError>> {
903    // add a prefix to parameters to efficiently prevent name collisions
904    let p_header_x_session_token = x_session_token;
905    let p_query_organization = organization;
906
907    let uri_str = format!("{}/self-service/settings/api", configuration.base_path);
908    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
909
910    if let Some(ref param_value) = p_query_organization {
911        req_builder = req_builder.query(&[("organization", &param_value.to_string())]);
912    }
913    if let Some(ref user_agent) = configuration.user_agent {
914        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
915    }
916    if let Some(param_value) = p_header_x_session_token {
917        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
918    }
919
920    let req = req_builder.build()?;
921    let resp = configuration.client.execute(req).await?;
922
923    let status = resp.status();
924    let content_type = resp
925        .headers()
926        .get("content-type")
927        .and_then(|v| v.to_str().ok())
928        .unwrap_or("application/octet-stream");
929    let content_type = super::ContentType::from(content_type);
930
931    if !status.is_client_error() && !status.is_server_error() {
932        let content = resp.text().await?;
933        match content_type {
934            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
935            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
936            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SettingsFlow`")))),
937        }
938    } else {
939        let content = resp.text().await?;
940        let entity: Option<CreateNativeSettingsFlowError> = serde_json::from_str(&content).ok();
941        Err(Error::ResponseError(ResponseContent { status, content, entity }))
942    }
943}
944
945/// This endpoint initiates a verification flow for API clients such as mobile devices, smart TVs, and so on.  To fetch an existing verification flow call `/self-service/verification/flows?flow=<flow_id>`.  You MUST NOT use this endpoint in client-side (Single Page Apps, ReactJS, AngularJS) nor server-side (Java Server Pages, NodeJS, PHP, Golang, ...) browser applications. Using this endpoint in these applications will make you vulnerable to a variety of CSRF attacks.  This endpoint MUST ONLY be used in scenarios such as native mobile apps (React Native, Objective C, Swift, Java, ...).  More information can be found at [Ory Email and Phone Verification Documentation](https://www.ory.com/docs/kratos/self-service/flows/verify-email-account-activation).
946pub async fn create_native_verification_flow(configuration: &configuration::Configuration, return_to: Option<&str>) -> Result<models::VerificationFlow, Error<CreateNativeVerificationFlowError>> {
947    // add a prefix to parameters to efficiently prevent name collisions
948    let p_query_return_to = return_to;
949
950    let uri_str = format!("{}/self-service/verification/api", configuration.base_path);
951    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
952
953    if let Some(ref param_value) = p_query_return_to {
954        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
955    }
956    if let Some(ref user_agent) = configuration.user_agent {
957        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
958    }
959
960    let req = req_builder.build()?;
961    let resp = configuration.client.execute(req).await?;
962
963    let status = resp.status();
964    let content_type = resp
965        .headers()
966        .get("content-type")
967        .and_then(|v| v.to_str().ok())
968        .unwrap_or("application/octet-stream");
969    let content_type = super::ContentType::from(content_type);
970
971    if !status.is_client_error() && !status.is_server_error() {
972        let content = resp.text().await?;
973        match content_type {
974            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
975            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
976            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerificationFlow`")))),
977        }
978    } else {
979        let content = resp.text().await?;
980        let entity: Option<CreateNativeVerificationFlowError> = serde_json::from_str(&content).ok();
981        Err(Error::ResponseError(ResponseContent { status, content, entity }))
982    }
983}
984
985/// Deletes a dry-run OIDC test login flow. A flow whose debug payload has been captured requires the HMAC cookie set by the OIDC callback; a flow still in the initial choose-method state is deletable with just the flow ID (it carries no PII, and the admin may want to abandon it).
986pub async fn delete_test_login_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<(), Error<DeleteTestLoginFlowError>> {
987    // add a prefix to parameters to efficiently prevent name collisions
988    let p_query_id = id;
989    let p_header_cookie = cookie;
990
991    let uri_str = format!("{}/self-service/login/test", configuration.base_path);
992    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
993
994    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
995    if let Some(ref user_agent) = configuration.user_agent {
996        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
997    }
998    if let Some(param_value) = p_header_cookie {
999        req_builder = req_builder.header("Cookie", param_value.to_string());
1000    }
1001
1002    let req = req_builder.build()?;
1003    let resp = configuration.client.execute(req).await?;
1004
1005    let status = resp.status();
1006
1007    if !status.is_client_error() && !status.is_server_error() {
1008        Ok(())
1009    } else {
1010        let content = resp.text().await?;
1011        let entity: Option<DeleteTestLoginFlowError> = serde_json::from_str(&content).ok();
1012        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1013    }
1014}
1015
1016/// Calling this endpoint invalidates all except the current session that belong to the logged-in user. Session data are not deleted.
1017pub async fn disable_my_other_sessions(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::DeleteMySessionsCount, Error<DisableMyOtherSessionsError>> {
1018    // add a prefix to parameters to efficiently prevent name collisions
1019    let p_header_x_session_token = x_session_token;
1020    let p_header_cookie = cookie;
1021
1022    let uri_str = format!("{}/sessions", configuration.base_path);
1023    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1024
1025    if let Some(ref user_agent) = configuration.user_agent {
1026        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1027    }
1028    if let Some(param_value) = p_header_x_session_token {
1029        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1030    }
1031    if let Some(param_value) = p_header_cookie {
1032        req_builder = req_builder.header("Cookie", param_value.to_string());
1033    }
1034
1035    let req = req_builder.build()?;
1036    let resp = configuration.client.execute(req).await?;
1037
1038    let status = resp.status();
1039    let content_type = resp
1040        .headers()
1041        .get("content-type")
1042        .and_then(|v| v.to_str().ok())
1043        .unwrap_or("application/octet-stream");
1044    let content_type = super::ContentType::from(content_type);
1045
1046    if !status.is_client_error() && !status.is_server_error() {
1047        let content = resp.text().await?;
1048        match content_type {
1049            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1050            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::DeleteMySessionsCount`"))),
1051            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::DeleteMySessionsCount`")))),
1052        }
1053    } else {
1054        let content = resp.text().await?;
1055        let entity: Option<DisableMyOtherSessionsError> = serde_json::from_str(&content).ok();
1056        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1057    }
1058}
1059
1060/// Calling this endpoint invalidates the specified session. The current session cannot be revoked. Session data are not deleted.
1061pub async fn disable_my_session(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<(), Error<DisableMySessionError>> {
1062    // add a prefix to parameters to efficiently prevent name collisions
1063    let p_path_id = id;
1064    let p_header_x_session_token = x_session_token;
1065    let p_header_cookie = cookie;
1066
1067    let uri_str = format!("{}/sessions/{id}", configuration.base_path, id=crate::apis::urlencode(p_path_id));
1068    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1069
1070    if let Some(ref user_agent) = configuration.user_agent {
1071        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1072    }
1073    if let Some(param_value) = p_header_x_session_token {
1074        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1075    }
1076    if let Some(param_value) = p_header_cookie {
1077        req_builder = req_builder.header("Cookie", param_value.to_string());
1078    }
1079
1080    let req = req_builder.build()?;
1081    let resp = configuration.client.execute(req).await?;
1082
1083    let status = resp.status();
1084
1085    if !status.is_client_error() && !status.is_server_error() {
1086        Ok(())
1087    } else {
1088        let content = resp.text().await?;
1089        let entity: Option<DisableMySessionError> = serde_json::from_str(&content).ok();
1090        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1091    }
1092}
1093
1094pub async fn exchange_session_token(configuration: &configuration::Configuration, init_code: &str, return_to_code: &str) -> Result<models::SuccessfulNativeLogin, Error<ExchangeSessionTokenError>> {
1095    // add a prefix to parameters to efficiently prevent name collisions
1096    let p_query_init_code = init_code;
1097    let p_query_return_to_code = return_to_code;
1098
1099    let uri_str = format!("{}/sessions/token-exchange", configuration.base_path);
1100    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1101
1102    req_builder = req_builder.query(&[("init_code", &p_query_init_code.to_string())]);
1103    req_builder = req_builder.query(&[("return_to_code", &p_query_return_to_code.to_string())]);
1104    if let Some(ref user_agent) = configuration.user_agent {
1105        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1106    }
1107
1108    let req = req_builder.build()?;
1109    let resp = configuration.client.execute(req).await?;
1110
1111    let status = resp.status();
1112    let content_type = resp
1113        .headers()
1114        .get("content-type")
1115        .and_then(|v| v.to_str().ok())
1116        .unwrap_or("application/octet-stream");
1117    let content_type = super::ContentType::from(content_type);
1118
1119    if !status.is_client_error() && !status.is_server_error() {
1120        let content = resp.text().await?;
1121        match content_type {
1122            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1123            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1124            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulNativeLogin`")))),
1125        }
1126    } else {
1127        let content = resp.text().await?;
1128        let entity: Option<ExchangeSessionTokenError> = serde_json::from_str(&content).ok();
1129        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1130    }
1131}
1132
1133/// This endpoint returns the error associated with a user-facing self service errors.  This endpoint supports stub values to help you implement the error UI:  - `?id=stub:500` - returns a stub 500 (Internal Server Error) error.  More information can be found at [Ory Kratos User User Facing Error Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-facing-errors).
1134pub async fn get_flow_error(configuration: &configuration::Configuration, id: &str) -> Result<models::FlowError, Error<GetFlowErrorError>> {
1135    // add a prefix to parameters to efficiently prevent name collisions
1136    let p_query_id = id;
1137
1138    let uri_str = format!("{}/self-service/errors", configuration.base_path);
1139    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1140
1141    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1142    if let Some(ref user_agent) = configuration.user_agent {
1143        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1144    }
1145
1146    let req = req_builder.build()?;
1147    let resp = configuration.client.execute(req).await?;
1148
1149    let status = resp.status();
1150    let content_type = resp
1151        .headers()
1152        .get("content-type")
1153        .and_then(|v| v.to_str().ok())
1154        .unwrap_or("application/octet-stream");
1155    let content_type = super::ContentType::from(content_type);
1156
1157    if !status.is_client_error() && !status.is_server_error() {
1158        let content = resp.text().await?;
1159        match content_type {
1160            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1161            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::FlowError`"))),
1162            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::FlowError`")))),
1163        }
1164    } else {
1165        let content = resp.text().await?;
1166        let entity: Option<GetFlowErrorError> = serde_json::from_str(&content).ok();
1167        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1168    }
1169}
1170
1171/// This endpoint returns a login flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/login', async function (req, res) { const flow = await client.getLoginFlow(req.header('cookie'), req.query['flow'])  res.render('login', flow) }) ```  This request may fail due to several reasons. The `error.id` can be one of:  - `session_already_available`: The user is already signed in. - `self_service_flow_expired`: The flow is expired and you should request a new one.  More information can be found at [Ory Kratos User Login](https://www.ory.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1172pub async fn get_login_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::LoginFlow, Error<GetLoginFlowError>> {
1173    // add a prefix to parameters to efficiently prevent name collisions
1174    let p_query_id = id;
1175    let p_header_cookie = cookie;
1176
1177    let uri_str = format!("{}/self-service/login/flows", configuration.base_path);
1178    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1179
1180    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1181    if let Some(ref user_agent) = configuration.user_agent {
1182        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1183    }
1184    if let Some(param_value) = p_header_cookie {
1185        req_builder = req_builder.header("Cookie", param_value.to_string());
1186    }
1187
1188    let req = req_builder.build()?;
1189    let resp = configuration.client.execute(req).await?;
1190
1191    let status = resp.status();
1192    let content_type = resp
1193        .headers()
1194        .get("content-type")
1195        .and_then(|v| v.to_str().ok())
1196        .unwrap_or("application/octet-stream");
1197    let content_type = super::ContentType::from(content_type);
1198
1199    if !status.is_client_error() && !status.is_server_error() {
1200        let content = resp.text().await?;
1201        match content_type {
1202            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1203            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::LoginFlow`"))),
1204            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::LoginFlow`")))),
1205        }
1206    } else {
1207        let content = resp.text().await?;
1208        let entity: Option<GetLoginFlowError> = serde_json::from_str(&content).ok();
1209        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1210    }
1211}
1212
1213/// This endpoint returns a recovery flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/recovery', async function (req, res) { const flow = await client.getRecoveryFlow(req.header('Cookie'), req.query['flow'])  res.render('recovery', flow) }) ```  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
1214pub async fn get_recovery_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RecoveryFlow, Error<GetRecoveryFlowError>> {
1215    // add a prefix to parameters to efficiently prevent name collisions
1216    let p_query_id = id;
1217    let p_header_cookie = cookie;
1218
1219    let uri_str = format!("{}/self-service/recovery/flows", configuration.base_path);
1220    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1221
1222    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1223    if let Some(ref user_agent) = configuration.user_agent {
1224        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1225    }
1226    if let Some(param_value) = p_header_cookie {
1227        req_builder = req_builder.header("Cookie", param_value.to_string());
1228    }
1229
1230    let req = req_builder.build()?;
1231    let resp = configuration.client.execute(req).await?;
1232
1233    let status = resp.status();
1234    let content_type = resp
1235        .headers()
1236        .get("content-type")
1237        .and_then(|v| v.to_str().ok())
1238        .unwrap_or("application/octet-stream");
1239    let content_type = super::ContentType::from(content_type);
1240
1241    if !status.is_client_error() && !status.is_server_error() {
1242        let content = resp.text().await?;
1243        match content_type {
1244            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1245            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
1246            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RecoveryFlow`")))),
1247        }
1248    } else {
1249        let content = resp.text().await?;
1250        let entity: Option<GetRecoveryFlowError> = serde_json::from_str(&content).ok();
1251        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1252    }
1253}
1254
1255/// This endpoint returns a registration flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/registration', async function (req, res) { const flow = await client.getRegistrationFlow(req.header('cookie'), req.query['flow'])  res.render('registration', flow) }) ```  This request may fail due to several reasons. The `error.id` can be one of:  - `session_already_available`: The user is already signed in. - `self_service_flow_expired`: The flow is expired and you should request a new one.  More information can be found at [Ory Kratos User Login](https://www.ory.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1256pub async fn get_registration_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::RegistrationFlow, Error<GetRegistrationFlowError>> {
1257    // add a prefix to parameters to efficiently prevent name collisions
1258    let p_query_id = id;
1259    let p_header_cookie = cookie;
1260
1261    let uri_str = format!("{}/self-service/registration/flows", configuration.base_path);
1262    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1263
1264    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1265    if let Some(ref user_agent) = configuration.user_agent {
1266        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1267    }
1268    if let Some(param_value) = p_header_cookie {
1269        req_builder = req_builder.header("Cookie", param_value.to_string());
1270    }
1271
1272    let req = req_builder.build()?;
1273    let resp = configuration.client.execute(req).await?;
1274
1275    let status = resp.status();
1276    let content_type = resp
1277        .headers()
1278        .get("content-type")
1279        .and_then(|v| v.to_str().ok())
1280        .unwrap_or("application/octet-stream");
1281    let content_type = super::ContentType::from(content_type);
1282
1283    if !status.is_client_error() && !status.is_server_error() {
1284        let content = resp.text().await?;
1285        match content_type {
1286            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1287            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RegistrationFlow`"))),
1288            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RegistrationFlow`")))),
1289        }
1290    } else {
1291        let content = resp.text().await?;
1292        let entity: Option<GetRegistrationFlowError> = serde_json::from_str(&content).ok();
1293        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1294    }
1295}
1296
1297/// When accessing this endpoint through Ory Kratos' Public API you must ensure that either the Ory Kratos Session Cookie or the Ory Kratos Session Token are set.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.  You can access this endpoint without credentials when using Ory Kratos' Admin API.  If this endpoint is called via an AJAX request, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. - `session_inactive`: No Ory Session was found - sign in a user first. - `security_identity_mismatch`: The flow was interrupted with `session_refresh_required` but apparently some other identity logged in instead.  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
1298pub async fn get_settings_flow(configuration: &configuration::Configuration, id: &str, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<GetSettingsFlowError>> {
1299    // add a prefix to parameters to efficiently prevent name collisions
1300    let p_query_id = id;
1301    let p_header_x_session_token = x_session_token;
1302    let p_header_cookie = cookie;
1303
1304    let uri_str = format!("{}/self-service/settings/flows", configuration.base_path);
1305    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1306
1307    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1308    if let Some(ref user_agent) = configuration.user_agent {
1309        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1310    }
1311    if let Some(param_value) = p_header_x_session_token {
1312        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1313    }
1314    if let Some(param_value) = p_header_cookie {
1315        req_builder = req_builder.header("Cookie", param_value.to_string());
1316    }
1317
1318    let req = req_builder.build()?;
1319    let resp = configuration.client.execute(req).await?;
1320
1321    let status = resp.status();
1322    let content_type = resp
1323        .headers()
1324        .get("content-type")
1325        .and_then(|v| v.to_str().ok())
1326        .unwrap_or("application/octet-stream");
1327    let content_type = super::ContentType::from(content_type);
1328
1329    if !status.is_client_error() && !status.is_server_error() {
1330        let content = resp.text().await?;
1331        match content_type {
1332            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1333            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
1334            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SettingsFlow`")))),
1335        }
1336    } else {
1337        let content = resp.text().await?;
1338        let entity: Option<GetSettingsFlowError> = serde_json::from_str(&content).ok();
1339        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1340    }
1341}
1342
1343/// This endpoint returns a verification flow's context with, for example, error details and other information.  Browser flows expect the anti-CSRF cookie to be included in the request's HTTP Cookie Header. For AJAX requests you must ensure that cookies are included in the request or requests will fail.  If you use the browser-flow for server-side apps, the services need to run on a common top-level-domain and you need to forward the incoming HTTP Cookie header to this endpoint:  ```js pseudo-code example router.get('/recovery', async function (req, res) { const flow = await client.getVerificationFlow(req.header('cookie'), req.query['flow'])  res.render('verification', flow) }) ```  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.com/docs/kratos/self-service/flows/verify-email-account-activation).
1344pub async fn get_verification_flow(configuration: &configuration::Configuration, id: &str, cookie: Option<&str>) -> Result<models::VerificationFlow, Error<GetVerificationFlowError>> {
1345    // add a prefix to parameters to efficiently prevent name collisions
1346    let p_query_id = id;
1347    let p_header_cookie = cookie;
1348
1349    let uri_str = format!("{}/self-service/verification/flows", configuration.base_path);
1350    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1351
1352    req_builder = req_builder.query(&[("id", &p_query_id.to_string())]);
1353    if let Some(ref user_agent) = configuration.user_agent {
1354        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1355    }
1356    if let Some(param_value) = p_header_cookie {
1357        req_builder = req_builder.header("Cookie", param_value.to_string());
1358    }
1359
1360    let req = req_builder.build()?;
1361    let resp = configuration.client.execute(req).await?;
1362
1363    let status = resp.status();
1364    let content_type = resp
1365        .headers()
1366        .get("content-type")
1367        .and_then(|v| v.to_str().ok())
1368        .unwrap_or("application/octet-stream");
1369    let content_type = super::ContentType::from(content_type);
1370
1371    if !status.is_client_error() && !status.is_server_error() {
1372        let content = resp.text().await?;
1373        match content_type {
1374            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1375            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
1376            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerificationFlow`")))),
1377        }
1378    } else {
1379        let content = resp.text().await?;
1380        let entity: Option<GetVerificationFlowError> = serde_json::from_str(&content).ok();
1381        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1382    }
1383}
1384
1385/// This endpoint provides JavaScript which is needed in order to perform WebAuthn login and registration.  If you are building a JavaScript Browser App (e.g. in ReactJS or AngularJS) you will need to load this file:  ```html <script src=\"https://public-kratos.example.org/.well-known/ory/webauthn.js\" type=\"script\" async /> ```  More information can be found at [Ory Kratos User Login](https://www.ory.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1386pub async fn get_web_authn_java_script(configuration: &configuration::Configuration, ) -> Result<String, Error<GetWebAuthnJavaScriptError>> {
1387
1388    let uri_str = format!("{}/.well-known/ory/webauthn.js", configuration.base_path);
1389    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1390
1391    if let Some(ref user_agent) = configuration.user_agent {
1392        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1393    }
1394
1395    let req = req_builder.build()?;
1396    let resp = configuration.client.execute(req).await?;
1397
1398    let status = resp.status();
1399    let content_type = resp
1400        .headers()
1401        .get("content-type")
1402        .and_then(|v| v.to_str().ok())
1403        .unwrap_or("application/octet-stream");
1404    let content_type = super::ContentType::from(content_type);
1405
1406    if !status.is_client_error() && !status.is_server_error() {
1407        let content = resp.text().await?;
1408        match content_type {
1409            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1410            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `String`"))),
1411            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `String`")))),
1412        }
1413    } else {
1414        let content = resp.text().await?;
1415        let entity: Option<GetWebAuthnJavaScriptError> = serde_json::from_str(&content).ok();
1416        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1417    }
1418}
1419
1420/// This endpoint serves the WebAuthn Related Origin Requests document specified in https://www.w3.org/TR/webauthn-3/#sctn-related-origins. It lists the web origins allowed to use this domain as their WebAuthn relying party ID. Browsers fetch it when a page requests a relying party ID that does not match the page's own origin.  The document contains the relying party origins configured for the enabled WebAuthn and passkey methods.
1421pub async fn get_web_authn_related_origins(configuration: &configuration::Configuration, ) -> Result<models::WebAuthnRelatedOrigins, Error<GetWebAuthnRelatedOriginsError>> {
1422
1423    let uri_str = format!("{}/.well-known/webauthn", configuration.base_path);
1424    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1425
1426    if let Some(ref user_agent) = configuration.user_agent {
1427        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1428    }
1429
1430    let req = req_builder.build()?;
1431    let resp = configuration.client.execute(req).await?;
1432
1433    let status = resp.status();
1434    let content_type = resp
1435        .headers()
1436        .get("content-type")
1437        .and_then(|v| v.to_str().ok())
1438        .unwrap_or("application/octet-stream");
1439    let content_type = super::ContentType::from(content_type);
1440
1441    if !status.is_client_error() && !status.is_server_error() {
1442        let content = resp.text().await?;
1443        match content_type {
1444            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1445            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::WebAuthnRelatedOrigins`"))),
1446            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::WebAuthnRelatedOrigins`")))),
1447        }
1448    } else {
1449        let content = resp.text().await?;
1450        let entity: Option<GetWebAuthnRelatedOriginsError> = serde_json::from_str(&content).ok();
1451        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1452    }
1453}
1454
1455/// This endpoint implements the W3C \"change password URL\" well-known location by redirecting the browser to the configured settings UI. Password managers follow this redirect to take users straight to the page where they can change their password.
1456pub async fn get_well_known_change_password(configuration: &configuration::Configuration, ) -> Result<models::ErrorGeneric, Error<GetWellKnownChangePasswordError>> {
1457
1458    let uri_str = format!("{}/.well-known/change-password", configuration.base_path);
1459    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1460
1461    if let Some(ref user_agent) = configuration.user_agent {
1462        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1463    }
1464
1465    let req = req_builder.build()?;
1466    let resp = configuration.client.execute(req).await?;
1467
1468    let status = resp.status();
1469    let content_type = resp
1470        .headers()
1471        .get("content-type")
1472        .and_then(|v| v.to_str().ok())
1473        .unwrap_or("application/octet-stream");
1474    let content_type = super::ContentType::from(content_type);
1475
1476    if !status.is_client_error() && !status.is_server_error() {
1477        let content = resp.text().await?;
1478        match content_type {
1479            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1480            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::ErrorGeneric`"))),
1481            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::ErrorGeneric`")))),
1482        }
1483    } else {
1484        let content = resp.text().await?;
1485        let entity: Option<GetWellKnownChangePasswordError> = serde_json::from_str(&content).ok();
1486        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1487    }
1488}
1489
1490/// This endpoints returns all other active sessions that belong to the logged-in user. The current session can be retrieved by calling the `/sessions/whoami` endpoint.
1491pub async fn list_my_sessions(configuration: &configuration::Configuration, per_page: Option<i64>, page: Option<i64>, page_size: Option<i64>, page_token: Option<&str>, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<Vec<models::Session>, Error<ListMySessionsError>> {
1492    // add a prefix to parameters to efficiently prevent name collisions
1493    let p_query_per_page = per_page;
1494    let p_query_page = page;
1495    let p_query_page_size = page_size;
1496    let p_query_page_token = page_token;
1497    let p_header_x_session_token = x_session_token;
1498    let p_header_cookie = cookie;
1499
1500    let uri_str = format!("{}/sessions", configuration.base_path);
1501    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1502
1503    if let Some(ref param_value) = p_query_per_page {
1504        req_builder = req_builder.query(&[("per_page", &param_value.to_string())]);
1505    }
1506    if let Some(ref param_value) = p_query_page {
1507        req_builder = req_builder.query(&[("page", &param_value.to_string())]);
1508    }
1509    if let Some(ref param_value) = p_query_page_size {
1510        req_builder = req_builder.query(&[("page_size", &param_value.to_string())]);
1511    }
1512    if let Some(ref param_value) = p_query_page_token {
1513        req_builder = req_builder.query(&[("page_token", &param_value.to_string())]);
1514    }
1515    if let Some(ref user_agent) = configuration.user_agent {
1516        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1517    }
1518    if let Some(param_value) = p_header_x_session_token {
1519        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1520    }
1521    if let Some(param_value) = p_header_cookie {
1522        req_builder = req_builder.header("Cookie", param_value.to_string());
1523    }
1524
1525    let req = req_builder.build()?;
1526    let resp = configuration.client.execute(req).await?;
1527
1528    let status = resp.status();
1529    let content_type = resp
1530        .headers()
1531        .get("content-type")
1532        .and_then(|v| v.to_str().ok())
1533        .unwrap_or("application/octet-stream");
1534    let content_type = super::ContentType::from(content_type);
1535
1536    if !status.is_client_error() && !status.is_server_error() {
1537        let content = resp.text().await?;
1538        match content_type {
1539            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1540            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `Vec&lt;models::Session&gt;`"))),
1541            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `Vec&lt;models::Session&gt;`")))),
1542        }
1543    } else {
1544        let content = resp.text().await?;
1545        let entity: Option<ListMySessionsError> = serde_json::from_str(&content).ok();
1546        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1547    }
1548}
1549
1550/// Use this endpoint to log out an identity using an Ory Session Token. If the Ory Session Token was successfully revoked, the server returns a 204 No Content response. A 204 No Content response is also sent when the Ory Session Token has been revoked already before.  If the Ory Session Token is malformed or does not exist a 403 Forbidden response will be returned.  This endpoint does not remove any HTTP Cookies - use the Browser-Based Self-Service Logout Flow instead.
1551pub async fn perform_native_logout(configuration: &configuration::Configuration, perform_native_logout_body: models::PerformNativeLogoutBody) -> Result<(), Error<PerformNativeLogoutError>> {
1552    // add a prefix to parameters to efficiently prevent name collisions
1553    let p_body_perform_native_logout_body = perform_native_logout_body;
1554
1555    let uri_str = format!("{}/self-service/logout/api", configuration.base_path);
1556    let mut req_builder = configuration.client.request(reqwest::Method::DELETE, &uri_str);
1557
1558    if let Some(ref user_agent) = configuration.user_agent {
1559        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1560    }
1561    req_builder = req_builder.json(&p_body_perform_native_logout_body);
1562
1563    let req = req_builder.build()?;
1564    let resp = configuration.client.execute(req).await?;
1565
1566    let status = resp.status();
1567
1568    if !status.is_client_error() && !status.is_server_error() {
1569        Ok(())
1570    } else {
1571        let content = resp.text().await?;
1572        let entity: Option<PerformNativeLogoutError> = serde_json::from_str(&content).ok();
1573        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1574    }
1575}
1576
1577/// Uses the HTTP Headers in the GET request to determine (e.g. by using checking the cookies) who is authenticated. Returns a session object in the body or 401 if the credentials are invalid or no credentials were sent. When the request it successful it adds the user ID to the 'X-Kratos-Authenticated-Identity-Id' header in the response.  If you call this endpoint from a server-side application, you must forward the HTTP Cookie Header to this endpoint:  ```js pseudo-code example router.get('/protected-endpoint', async function (req, res) { const session = await client.toSession(undefined, req.header('cookie'))  console.log(session) }) ```  When calling this endpoint from a non-browser application (e.g. mobile app) you must include the session token:  ```js pseudo-code example ... const session = await client.toSession(\"the-session-token\")  console.log(session) ```  When using a token template, the token is included in the `tokenized` field of the session.  ```js pseudo-code example ... const session = await client.toSession(\"the-session-token\", { tokenize_as: \"example-jwt-template\" })  console.log(session.tokenized) // The JWT ```  Depending on your configuration this endpoint might return a 403 status code if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.  This endpoint is useful for:  - AJAX calls. Remember to send credentials and set up CORS correctly! - Reverse proxies and API Gateways - Server-side calls - use the `X-Session-Token` header!  This endpoint authenticates users by checking:  - if the `Cookie` HTTP header was set containing an Ory Kratos Session Cookie; - if the `Authorization: bearer <ory-session-token>` HTTP header was set with a valid Ory Kratos Session Token; - if the `X-Session-Token` HTTP header was set with a valid Ory Kratos Session Token.  If none of these headers are set or the cookie or token are invalid, the endpoint returns a HTTP 401 status code.  As explained above, this request may fail due to several reasons. The `error.id` can be one of:  - `session_inactive`: No active session was found in the request (e.g. no Ory Session Cookie / Ory Session Token). - `session_aal2_required`: An active session was found but it does not fulfil the Authenticator Assurance Level, implying that the session must (e.g.) authenticate the second factor. - `session_aal2_enrollment_required`: An active session was found but the required Authenticator Assurance Level can not be reached because the identity has no second factor enrolled. Follow `redirect_browser_to` to the settings flow to enroll one.
1578pub async fn to_session(configuration: &configuration::Configuration, x_session_token: Option<&str>, cookie: Option<&str>, tokenize_as: Option<&str>) -> Result<models::Session, Error<ToSessionError>> {
1579    // add a prefix to parameters to efficiently prevent name collisions
1580    let p_header_x_session_token = x_session_token;
1581    let p_header_cookie = cookie;
1582    let p_query_tokenize_as = tokenize_as;
1583
1584    let uri_str = format!("{}/sessions/whoami", configuration.base_path);
1585    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1586
1587    if let Some(ref param_value) = p_query_tokenize_as {
1588        req_builder = req_builder.query(&[("tokenize_as", &param_value.to_string())]);
1589    }
1590    if let Some(ref user_agent) = configuration.user_agent {
1591        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1592    }
1593    if let Some(param_value) = p_header_x_session_token {
1594        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1595    }
1596    if let Some(param_value) = p_header_cookie {
1597        req_builder = req_builder.header("Cookie", param_value.to_string());
1598    }
1599
1600    let req = req_builder.build()?;
1601    let resp = configuration.client.execute(req).await?;
1602
1603    let status = resp.status();
1604    let content_type = resp
1605        .headers()
1606        .get("content-type")
1607        .and_then(|v| v.to_str().ok())
1608        .unwrap_or("application/octet-stream");
1609    let content_type = super::ContentType::from(content_type);
1610
1611    if !status.is_client_error() && !status.is_server_error() {
1612        let content = resp.text().await?;
1613        match content_type {
1614            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1615            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::Session`"))),
1616            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::Session`")))),
1617        }
1618    } else {
1619        let content = resp.text().await?;
1620        let entity: Option<ToSessionError> = serde_json::from_str(&content).ok();
1621        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1622    }
1623}
1624
1625/// Use this endpoint to submit a token from a FedCM provider through `navigator.credentials.get` and log the user in. The parameters from `navigator.credentials.get` must have come from `GET self-service/fed-cm/parameters`.
1626pub async fn update_fedcm_flow(configuration: &configuration::Configuration, update_fedcm_flow_body: models::UpdateFedcmFlowBody) -> Result<models::SuccessfulNativeLogin, Error<UpdateFedcmFlowError>> {
1627    // add a prefix to parameters to efficiently prevent name collisions
1628    let p_body_update_fedcm_flow_body = update_fedcm_flow_body;
1629
1630    let uri_str = format!("{}/self-service/fed-cm/token", configuration.base_path);
1631    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1632
1633    if let Some(ref user_agent) = configuration.user_agent {
1634        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1635    }
1636    req_builder = req_builder.json(&p_body_update_fedcm_flow_body);
1637
1638    let req = req_builder.build()?;
1639    let resp = configuration.client.execute(req).await?;
1640
1641    let status = resp.status();
1642    let content_type = resp
1643        .headers()
1644        .get("content-type")
1645        .and_then(|v| v.to_str().ok())
1646        .unwrap_or("application/octet-stream");
1647    let content_type = super::ContentType::from(content_type);
1648
1649    if !status.is_client_error() && !status.is_server_error() {
1650        let content = resp.text().await?;
1651        match content_type {
1652            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1653            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1654            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulNativeLogin`")))),
1655        }
1656    } else {
1657        let content = resp.text().await?;
1658        let entity: Option<UpdateFedcmFlowError> = serde_json::from_str(&content).ok();
1659        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1660    }
1661}
1662
1663/// Use this endpoint to complete a login flow. This endpoint behaves differently for API and browser flows.  API flows expect `application/json` to be sent in the body and responds with - HTTP 200 and a application/json body with the session token on success; - HTTP 410 if the original flow expired with the appropriate error messages set and optionally a `use_flow_id` parameter in the body; - HTTP 400 on form validation errors.  Browser flows expect a Content-Type of `application/x-www-form-urlencoded` or `application/json` to be sent in the body and respond with - a HTTP 303 redirect to the post/after login URL or the `return_to` value if it was set and if the login succeeded; - a HTTP 303 redirect to the login UI URL with the flow ID containing the validation errors otherwise.  Browser flows with an accept header of `application/json` will not redirect but instead respond with - HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; - HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; - HTTP 400 on form validation errors.  If this endpoint is called with `Accept: application/json` in the header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  - `session_already_available`: The user is already signed in. - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. - `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! - `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Login](https://www.ory.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1664pub async fn update_login_flow(configuration: &configuration::Configuration, flow: &str, update_login_flow_body: models::UpdateLoginFlowBody, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::SuccessfulNativeLogin, Error<UpdateLoginFlowError>> {
1665    // add a prefix to parameters to efficiently prevent name collisions
1666    let p_query_flow = flow;
1667    let p_body_update_login_flow_body = update_login_flow_body;
1668    let p_header_x_session_token = x_session_token;
1669    let p_header_cookie = cookie;
1670
1671    let uri_str = format!("{}/self-service/login", configuration.base_path);
1672    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1673
1674    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1675    if let Some(ref user_agent) = configuration.user_agent {
1676        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1677    }
1678    if let Some(param_value) = p_header_x_session_token {
1679        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1680    }
1681    if let Some(param_value) = p_header_cookie {
1682        req_builder = req_builder.header("Cookie", param_value.to_string());
1683    }
1684    req_builder = req_builder.json(&p_body_update_login_flow_body);
1685
1686    let req = req_builder.build()?;
1687    let resp = configuration.client.execute(req).await?;
1688
1689    let status = resp.status();
1690    let content_type = resp
1691        .headers()
1692        .get("content-type")
1693        .and_then(|v| v.to_str().ok())
1694        .unwrap_or("application/octet-stream");
1695    let content_type = super::ContentType::from(content_type);
1696
1697    if !status.is_client_error() && !status.is_server_error() {
1698        let content = resp.text().await?;
1699        match content_type {
1700            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1701            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeLogin`"))),
1702            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulNativeLogin`")))),
1703        }
1704    } else {
1705        let content = resp.text().await?;
1706        let entity: Option<UpdateLoginFlowError> = serde_json::from_str(&content).ok();
1707        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1708    }
1709}
1710
1711/// This endpoint logs out an identity in a self-service manner.  If the `Accept` HTTP header is not set to `application/json`, the browser will be redirected (HTTP 303 See Other) to the `return_to` parameter of the initial request or fall back to `urls.default_return_to`.  If the `Accept` HTTP header is set to `application/json`, a 204 No Content response will be sent on successful logout instead.  This endpoint is NOT INTENDED for API clients and only works with browsers (Chrome, Firefox, ...). For API clients you can call the `/self-service/logout/api` URL directly with the Ory Session Token.  More information can be found at [Ory Kratos User Logout Documentation](https://www.ory.com/docs/next/kratos/self-service/flows/user-logout).
1712pub async fn update_logout_flow(configuration: &configuration::Configuration, token: Option<&str>, return_to: Option<&str>, cookie: Option<&str>) -> Result<(), Error<UpdateLogoutFlowError>> {
1713    // add a prefix to parameters to efficiently prevent name collisions
1714    let p_query_token = token;
1715    let p_query_return_to = return_to;
1716    let p_header_cookie = cookie;
1717
1718    let uri_str = format!("{}/self-service/logout", configuration.base_path);
1719    let mut req_builder = configuration.client.request(reqwest::Method::GET, &uri_str);
1720
1721    if let Some(ref param_value) = p_query_token {
1722        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1723    }
1724    if let Some(ref param_value) = p_query_return_to {
1725        req_builder = req_builder.query(&[("return_to", &param_value.to_string())]);
1726    }
1727    if let Some(ref user_agent) = configuration.user_agent {
1728        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1729    }
1730    if let Some(param_value) = p_header_cookie {
1731        req_builder = req_builder.header("Cookie", param_value.to_string());
1732    }
1733
1734    let req = req_builder.build()?;
1735    let resp = configuration.client.execute(req).await?;
1736
1737    let status = resp.status();
1738
1739    if !status.is_client_error() && !status.is_server_error() {
1740        Ok(())
1741    } else {
1742        let content = resp.text().await?;
1743        let entity: Option<UpdateLogoutFlowError> = serde_json::from_str(&content).ok();
1744        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1745    }
1746}
1747
1748/// Use this endpoint to update a recovery flow. This endpoint behaves differently for API and browser flows and has several states:  - `choose_method` expects `flow` (in the URL query) and `email` (in the body) to be sent and works with API- and Browser-initiated flows. - For API clients and Browser clients with HTTP Header `Accept: application/json` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid. and a HTTP 303 See Other redirect with a fresh recovery flow if the flow was otherwise invalid (e.g. expired). - For Browser clients without HTTP Header `Accept` or with `Accept: text/_*` it returns a HTTP 303 See Other redirect to the Recovery UI URL with the Recovery Flow ID appended. - `sent_email` is the success state after `choose_method` for the `link` method and allows the user to request another recovery email. It works for both API and Browser-initiated flows and returns the same responses as the flow in `choose_method` state. - `passed_challenge` expects a `token` to be sent in the URL query and given the nature of the flow (\"sending a recovery link\") does not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Recover UI URL with a new Recovery Flow ID which contains an error message that the recovery link was invalid.  More information can be found at [Ory Kratos Account Recovery Documentation](../self-service/flows/account-recovery).
1749pub async fn update_recovery_flow(configuration: &configuration::Configuration, flow: &str, update_recovery_flow_body: models::UpdateRecoveryFlowBody, token: Option<&str>, cookie: Option<&str>) -> Result<models::RecoveryFlow, Error<UpdateRecoveryFlowError>> {
1750    // add a prefix to parameters to efficiently prevent name collisions
1751    let p_query_flow = flow;
1752    let p_body_update_recovery_flow_body = update_recovery_flow_body;
1753    let p_query_token = token;
1754    let p_header_cookie = cookie;
1755
1756    let uri_str = format!("{}/self-service/recovery", configuration.base_path);
1757    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1758
1759    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1760    if let Some(ref param_value) = p_query_token {
1761        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1762    }
1763    if let Some(ref user_agent) = configuration.user_agent {
1764        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1765    }
1766    if let Some(param_value) = p_header_cookie {
1767        req_builder = req_builder.header("Cookie", param_value.to_string());
1768    }
1769    req_builder = req_builder.json(&p_body_update_recovery_flow_body);
1770
1771    let req = req_builder.build()?;
1772    let resp = configuration.client.execute(req).await?;
1773
1774    let status = resp.status();
1775    let content_type = resp
1776        .headers()
1777        .get("content-type")
1778        .and_then(|v| v.to_str().ok())
1779        .unwrap_or("application/octet-stream");
1780    let content_type = super::ContentType::from(content_type);
1781
1782    if !status.is_client_error() && !status.is_server_error() {
1783        let content = resp.text().await?;
1784        match content_type {
1785            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1786            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::RecoveryFlow`"))),
1787            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::RecoveryFlow`")))),
1788        }
1789    } else {
1790        let content = resp.text().await?;
1791        let entity: Option<UpdateRecoveryFlowError> = serde_json::from_str(&content).ok();
1792        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1793    }
1794}
1795
1796/// Use this endpoint to complete a registration flow by sending an identity's traits and password. This endpoint behaves differently for API and browser flows.  API flows expect `application/json` to be sent in the body and respond with - HTTP 200 and a application/json body with the created identity success - if the session hook is configured the `session` and `session_token` will also be included; - HTTP 410 if the original flow expired with the appropriate error messages set and optionally a `use_flow_id` parameter in the body; - HTTP 400 on form validation errors.  Browser flows expect a Content-Type of `application/x-www-form-urlencoded` or `application/json` to be sent in the body and respond with - a HTTP 303 redirect to the post/after registration URL or the `return_to` value if it was set and if the registration succeeded; - a HTTP 303 redirect to the registration UI URL with the flow ID containing the validation errors otherwise.  Browser flows with an accept header of `application/json` will not redirect but instead respond with - HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; - HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; - HTTP 400 on form validation errors.  If this endpoint is called with `Accept: application/json` in the header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  - `session_already_available`: The user is already signed in. - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. - `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! - `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Login](https://www.ory.com/docs/kratos/self-service/flows/user-login) and [User Registration Documentation](https://www.ory.com/docs/kratos/self-service/flows/user-registration).
1797pub async fn update_registration_flow(configuration: &configuration::Configuration, flow: &str, update_registration_flow_body: models::UpdateRegistrationFlowBody, cookie: Option<&str>) -> Result<models::SuccessfulNativeRegistration, Error<UpdateRegistrationFlowError>> {
1798    // add a prefix to parameters to efficiently prevent name collisions
1799    let p_query_flow = flow;
1800    let p_body_update_registration_flow_body = update_registration_flow_body;
1801    let p_header_cookie = cookie;
1802
1803    let uri_str = format!("{}/self-service/registration", configuration.base_path);
1804    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1805
1806    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1807    if let Some(ref user_agent) = configuration.user_agent {
1808        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1809    }
1810    if let Some(param_value) = p_header_cookie {
1811        req_builder = req_builder.header("Cookie", param_value.to_string());
1812    }
1813    req_builder = req_builder.json(&p_body_update_registration_flow_body);
1814
1815    let req = req_builder.build()?;
1816    let resp = configuration.client.execute(req).await?;
1817
1818    let status = resp.status();
1819    let content_type = resp
1820        .headers()
1821        .get("content-type")
1822        .and_then(|v| v.to_str().ok())
1823        .unwrap_or("application/octet-stream");
1824    let content_type = super::ContentType::from(content_type);
1825
1826    if !status.is_client_error() && !status.is_server_error() {
1827        let content = resp.text().await?;
1828        match content_type {
1829            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1830            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SuccessfulNativeRegistration`"))),
1831            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SuccessfulNativeRegistration`")))),
1832        }
1833    } else {
1834        let content = resp.text().await?;
1835        let entity: Option<UpdateRegistrationFlowError> = serde_json::from_str(&content).ok();
1836        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1837    }
1838}
1839
1840/// Use this endpoint to complete a settings flow by sending an identity's updated password. This endpoint behaves differently for API and browser flows.  API-initiated flows expect `application/json` to be sent in the body and respond with - HTTP 200 and an application/json body with the session token on success; - HTTP 303 redirect to a fresh settings flow if the original flow expired with the appropriate error messages set; - HTTP 400 on form validation errors. - HTTP 401 when the endpoint is called without a valid session token. - HTTP 403 when `selfservice.flows.settings.privileged_session_max_age` was reached or the session's AAL is too low. Implies that the user needs to re-authenticate.  Browser flows without HTTP Header `Accept` or with `Accept: text/_*` respond with - a HTTP 303 redirect to the post/after settings URL or the `return_to` value if it was set and if the flow succeeded; - a HTTP 303 redirect to the Settings UI URL with the flow ID containing the validation errors otherwise. - a HTTP 303 redirect to the login endpoint when `selfservice.flows.settings.privileged_session_max_age` was reached or the session's AAL is too low.  Browser flows with HTTP Header `Accept: application/json` respond with - HTTP 200 and a application/json body with the signed in identity and a `Set-Cookie` header on success; - HTTP 303 redirect to a fresh login flow if the original flow expired with the appropriate error messages set; - HTTP 401 when the endpoint is called without a valid session cookie. - HTTP 403 when the page is accessed without a session cookie or the session's AAL is too low. - HTTP 400 on form validation errors.  Depending on your configuration this endpoint might return a 403 error if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor (happens automatically for server-side browser flows) or change the configuration.  If this endpoint is called with a `Accept: application/json` HTTP header, the response contains the flow without a redirect. In the case of an error, the `error.id` of the JSON response body can be one of:  - `session_refresh_required`: The identity requested to change something that needs a privileged session. Redirect the identity to the login init endpoint with query parameters `?refresh=true&return_to=<the-current-browser-url>`, or initiate a refresh login flow otherwise. - `security_csrf_violation`: Unable to fetch the flow because a CSRF violation occurred. - `session_inactive`: No Ory Session was found - sign in a user first. - `security_identity_mismatch`: The flow was interrupted with `session_refresh_required` but apparently some other identity logged in instead. - `security_identity_mismatch`: The requested `?return_to` address is not allowed to be used. Adjust this in the configuration! - `browser_location_change_required`: Usually sent when an AJAX request indicates that the browser needs to open a specific URL. Most likely used in Social Sign In flows.  More information can be found at [Ory Kratos User Settings & Profile Management Documentation](../self-service/flows/user-settings).
1841pub async fn update_settings_flow(configuration: &configuration::Configuration, flow: &str, update_settings_flow_body: models::UpdateSettingsFlowBody, x_session_token: Option<&str>, cookie: Option<&str>) -> Result<models::SettingsFlow, Error<UpdateSettingsFlowError>> {
1842    // add a prefix to parameters to efficiently prevent name collisions
1843    let p_query_flow = flow;
1844    let p_body_update_settings_flow_body = update_settings_flow_body;
1845    let p_header_x_session_token = x_session_token;
1846    let p_header_cookie = cookie;
1847
1848    let uri_str = format!("{}/self-service/settings", configuration.base_path);
1849    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1850
1851    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1852    if let Some(ref user_agent) = configuration.user_agent {
1853        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1854    }
1855    if let Some(param_value) = p_header_x_session_token {
1856        req_builder = req_builder.header("X-Session-Token", param_value.to_string());
1857    }
1858    if let Some(param_value) = p_header_cookie {
1859        req_builder = req_builder.header("Cookie", param_value.to_string());
1860    }
1861    req_builder = req_builder.json(&p_body_update_settings_flow_body);
1862
1863    let req = req_builder.build()?;
1864    let resp = configuration.client.execute(req).await?;
1865
1866    let status = resp.status();
1867    let content_type = resp
1868        .headers()
1869        .get("content-type")
1870        .and_then(|v| v.to_str().ok())
1871        .unwrap_or("application/octet-stream");
1872    let content_type = super::ContentType::from(content_type);
1873
1874    if !status.is_client_error() && !status.is_server_error() {
1875        let content = resp.text().await?;
1876        match content_type {
1877            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1878            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::SettingsFlow`"))),
1879            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::SettingsFlow`")))),
1880        }
1881    } else {
1882        let content = resp.text().await?;
1883        let entity: Option<UpdateSettingsFlowError> = serde_json::from_str(&content).ok();
1884        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1885    }
1886}
1887
1888/// Use this endpoint to complete a verification flow. This endpoint behaves differently for API and browser flows and has several states:  - `choose_method` expects `flow` (in the URL query) and `email` (in the body) to be sent and works with API- and Browser-initiated flows. - For API clients and Browser clients with HTTP Header `Accept: application/json` it either returns a HTTP 200 OK when the form is valid and HTTP 400 OK when the form is invalid and a HTTP 303 See Other redirect with a fresh verification flow if the flow was otherwise invalid (e.g. expired). - For Browser clients without HTTP Header `Accept` or with `Accept: text/_*` it returns a HTTP 303 See Other redirect to the Verification UI URL with the Verification Flow ID appended. - `sent_email` is the success state after `choose_method` when using the `link` method and allows the user to request another verification email. It works for both API and Browser-initiated flows and returns the same responses as the flow in `choose_method` state. - `passed_challenge` expects a `token` to be sent in the URL query and given the nature of the flow (\"sending a verification link\") does not have any API capabilities. The server responds with a HTTP 303 See Other redirect either to the Settings UI URL (if the link was valid) and instructs the user to update their password, or a redirect to the Verification UI URL with a new Verification Flow ID which contains an error message that the verification link was invalid.  More information can be found at [Ory Kratos Email and Phone Verification Documentation](https://www.ory.com/docs/kratos/self-service/flows/verify-email-account-activation).
1889pub async fn update_verification_flow(configuration: &configuration::Configuration, flow: &str, update_verification_flow_body: models::UpdateVerificationFlowBody, token: Option<&str>, cookie: Option<&str>) -> Result<models::VerificationFlow, Error<UpdateVerificationFlowError>> {
1890    // add a prefix to parameters to efficiently prevent name collisions
1891    let p_query_flow = flow;
1892    let p_body_update_verification_flow_body = update_verification_flow_body;
1893    let p_query_token = token;
1894    let p_header_cookie = cookie;
1895
1896    let uri_str = format!("{}/self-service/verification", configuration.base_path);
1897    let mut req_builder = configuration.client.request(reqwest::Method::POST, &uri_str);
1898
1899    req_builder = req_builder.query(&[("flow", &p_query_flow.to_string())]);
1900    if let Some(ref param_value) = p_query_token {
1901        req_builder = req_builder.query(&[("token", &param_value.to_string())]);
1902    }
1903    if let Some(ref user_agent) = configuration.user_agent {
1904        req_builder = req_builder.header(reqwest::header::USER_AGENT, user_agent.clone());
1905    }
1906    if let Some(param_value) = p_header_cookie {
1907        req_builder = req_builder.header("Cookie", param_value.to_string());
1908    }
1909    req_builder = req_builder.json(&p_body_update_verification_flow_body);
1910
1911    let req = req_builder.build()?;
1912    let resp = configuration.client.execute(req).await?;
1913
1914    let status = resp.status();
1915    let content_type = resp
1916        .headers()
1917        .get("content-type")
1918        .and_then(|v| v.to_str().ok())
1919        .unwrap_or("application/octet-stream");
1920    let content_type = super::ContentType::from(content_type);
1921
1922    if !status.is_client_error() && !status.is_server_error() {
1923        let content = resp.text().await?;
1924        match content_type {
1925            ContentType::Json => serde_json::from_str(&content).map_err(Error::from),
1926            ContentType::Text => return Err(Error::from(serde_json::Error::custom("Received `text/plain` content type response that cannot be converted to `models::VerificationFlow`"))),
1927            ContentType::Unsupported(unknown_type) => return Err(Error::from(serde_json::Error::custom(format!("Received `{unknown_type}` content type response that cannot be converted to `models::VerificationFlow`")))),
1928        }
1929    } else {
1930        let content = resp.text().await?;
1931        let entity: Option<UpdateVerificationFlowError> = serde_json::from_str(&content).ok();
1932        Err(Error::ResponseError(ResponseContent { status, content, entity }))
1933    }
1934}
1935