great-crayon-86888
02/13/2024, 11:52 AMchilly-king-10285
02/13/2024, 11:52 AMchilly-king-10285
02/13/2024, 11:52 AM/self-service/settings/api
endpoint. You need to include the session token in the request header as X-Session-Token
. Here is an example of how to do this using cURL: bash curl -s -X GET \ -H "Accept: application/json" \ -H "Authorization: bearer $sessionToken" \ <https://playground.projects.oryapis.com/self-service/settings/api>
Replace $sessionToken
with your actual session token. Please note that this endpoint should not be used in client-side or server-side browser applications as it can make you vulnerable to CSRF attacks. It is designed for use in scenarios such as native mobile apps. For more information, you can refer to the [Ory Kratos User Settings & Profile Management Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-settings). Sources: - [Ory API Reference - Create Settings Flow for Native Apps](https://www.ory.sh/docs/reference/api) - [Kratos Self-service - Initialize settings flow](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#user-and-profile-settings-updates-for-api-clients-and-clients-without-browsers)great-crayon-86888
02/13/2024, 11:54 AMchilly-king-10285
02/13/2024, 11:54 AMchilly-king-10285
02/13/2024, 11:55 AMbash # Inits a Login Flow actionUrl=$(\ curl -s -X GET -H "Accept: application/json" \ "<https://playground.projects.oryapis.com/self-service/login/api>" \ | jq -r '.ui.action'\ ) # Complete Login Flow with password method curl -s -X POST -H "Accept: application/json" -H "Content-Type: application/json" \ -d '{"identifier": "[[email protected]]", "password": "yourpassword", "method": "password"}' \ "$actionUrl" | jq
Replace "[[email protected]]"
with the user's email and "yourpassword"
with the user's password. The response will include a session_token
field which is the session token you can use for subsequent requests. Please note that this is just an example and you may need to adjust it according to your specific needs. For more information, you can refer to the [Ory Kratos User Login Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-login#api-clients). Sources: - [Kratos Self-service - User Login for API Clients](https://www.ory.sh/docs/kratos/self-service/flows/user-login#api-clients)great-crayon-86888
02/13/2024, 11:56 AMchilly-king-10285
02/13/2024, 11:56 AMchilly-king-10285
02/13/2024, 11:56 AM/self-service/recovery/api
endpoint. This will send a recovery link or a one-time code to the user's recovery address. 2. The user must access the link or enter the code they received to confirm their identity and ownership of the account. 3. After the user accesses the configured recovery method, they receive a privileged session and are taken to their account's settings page. 4. The user must create a new password to regain access to their account. Here is an example of how to initiate the recovery flow using cURL: bash curl -s -X GET -H "Accept: application/json" \ "<https://playground.projects.oryapis.com/self-service/recovery/api>"
Please note that the account recovery flow doesn't reset the user's second authentication factor. For more information, you can refer to the [Ory Kratos Account Recovery and Password Reset Documentation](https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset). Sources: - [Kratos Self-service - Account Recovery and Password Reset](https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset) - [Kratos Self-service - User Settings and Profile Updates](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#api-clients-and-clients-without-browsers)great-crayon-86888
02/13/2024, 11:57 AMchilly-king-10285
02/13/2024, 11:57 AMchilly-king-10285
02/13/2024, 11:57 AMauthenticated_at
timestamp is younger than the privileged_session_max_age
value defined in the configuration. This means that the user has recently authenticated, and therefore is allowed to perform sensitive actions. To change the duration of the privileged session, you can update the privileged_session_max_age
value in the Ory configuration. This can be done either through the Ory Console or the Ory CLI. Here is an example of how to update this value using the Ory CLI: bash ## List all available projects ory list projects ## Get config ory get identity-config {project-id} --format yaml > identity-config.yaml ## Update the configuration value for privileged session max age property ## For example, to set the privileged session duration to 15 minutes, enter `15m`. ## Update the value in the identity-config.yaml file ## Update the Ory Identities configuration using the file you worked with. ory update identity-config {project-id} --file identity-config.yaml
Please note that after the privileged session duration has passed, the user must re-authenticate to regain a privileged session. For more information, you can refer to the [Ory Kratos Session Management Documentation](https://www.ory.sh/docs/kratos/session-management/session-lifespan#privileged-sessions). Sources: - [Kratos Session Management - Privileged Sessions](https://www.ory.sh/docs/kratos/session-management/session-lifespan#privileged-sessions)great-crayon-86888
02/13/2024, 12:13 PMchilly-king-10285
02/13/2024, 12:13 PMchilly-king-10285
02/13/2024, 12:13 PM/self-service/recovery/api
endpoint. This will send a recovery link or a one-time code to the user's recovery address. bash curl -s -X GET -H "Accept: application/json" \ "<https://playground.projects.oryapis.com/self-service/recovery/api>"
2. Verify Ownership: The user must access the link or enter the code they received to confirm their identity and ownership of the account. This step is performed by the user, not programmatically. 3. Initiate the Settings Flow: After the user accesses the configured recovery method, they receive a privileged session and are taken to their account's settings page. You can initiate the settings flow by making a GET request to the /self-service/settings/api
endpoint. You need to include the session token in the request header as X-Session-Token
. bash curl -s -X GET \ -H "Accept: application/json" \ -H "Authorization: bearer $sessionToken" \ <https://playground.projects.oryapis.com/self-service/settings/api>
Replace $sessionToken
with your actual session token. 4. Reset Password: The user must create a new password to regain access to their account. This is done by making a POST request to the /self-service/settings/api
endpoint with the new password. Please note that the account recovery flow doesn't reset the user's second authentication factor. For more information, you can refer to the [Ory Kratos Account Recovery and Password Reset Documentation](https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset) and the [Ory Kratos User Settings & Profile Management Documentation](https://www.ory.sh/docs/kratos/self-service/flows/user-settings). Sources: - [Kratos Self-service - Account Recovery and Password Reset](https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset) - [Kratos Self-service - User Settings and Profile Updates](https://www.ory.sh/docs/kratos/self-service/flows/user-settings#api-clients-and-clients-without-browsers)great-crayon-86888
02/14/2024, 9:18 AMchilly-king-10285
02/14/2024, 9:18 AMchilly-king-10285
02/14/2024, 9:18 AMjson { "session": { "id": "..." // ... }, "session_token": "...", "identity": { "id": "..." // ... } }
However, this is for the registration flow, not the recovery flow. The recovery flow is designed to help users regain access to their account when they've forgotten their password or lost access to their account. It doesn't involve creating a new session, but rather verifying the user's identity. For more information, you can refer to the [Ory Kratos Account Recovery and Password Reset Documentation](https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset). Sources: - [Ory Kratos Documentation - Sign in after registration](https://www.ory.sh/docs/actions/session#native-app-registration) - [Ory Kratos Documentation - Account Recovery and Password Reset](https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset)great-crayon-86888
02/14/2024, 9:21 AMchilly-king-10285
02/14/2024, 9:21 AMchilly-king-10285
02/14/2024, 9:22 AMgreat-crayon-86888
02/14/2024, 9:24 AMchilly-king-10285
02/14/2024, 9:24 AMchilly-king-10285
02/14/2024, 9:24 AMgreat-crayon-86888
02/14/2024, 9:25 AMchilly-king-10285
02/14/2024, 9:25 AMchilly-king-10285
02/14/2024, 9:26 AM/self-service/recovery/api
endpoint. This will send a recovery link or a one-time code to the user's recovery address. bash curl -s -X GET -H "Accept: application/json" \ "<https://playground.projects.oryapis.com/self-service/recovery/api>"
2. Verify Ownership: The user must access the link or enter the code they received to confirm their identity and ownership of the account. This step is performed by the user, not programmatically. 3. Complete the Recovery Flow: After the user accesses the recovery link, they will be redirected to a page where they can set a new password. This page is part of your application and should render the form elements for the user to enter their new password. The form should be submitted to the ui.action
URL from the recovery flow. Here is an example of how to render the form using React: jsx import { Configuration, FrontendApi, RecoveryFlow, UiNode, UiNodeInputAttributes, } from "@ory/client" import { filterNodesByGroups, isUiNodeInputAttributes, } from "@ory/integrations/ui" import { useEffect, useState } from "react" import { useSearchParams } from "react-router-dom" const frontend = new FrontendApi( new Configuration({ basePath: "<http://localhost:4000>", // Use your local Ory Tunnel URL baseOptions: { withCredentials: true, // we need to include cookies }, }), ) export const Recovery = () => { const [flow, setFlow] = useState<RecoveryFlow>() const [searchParams] = useSearchParams() useEffect(() => { const id = searchParams.get("flow") frontend .getRecoveryFlow({ id: id, }) .then(({ data: flow }) => { // set the flow data setFlow(flow) }) .catch((err) => { // Couldn't create login flow // handle the error }) }, []) return flow ? ( <form action={flow.ui.action} method={flow.ui.method}> {filterNodesByGroups({ // render the form elements here })} </form> ) : null; }
Please note that the account recovery flow doesn't reset the user's second authentication factor. For more information, you can refer to the [Ory Kratos Account Recovery and Password Reset Documentation](https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset) and the [Ory Kratos Bring Your Own UI Documentation](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration). Sources: - [Kratos Self-service - Account Recovery and Password Reset](https://www.ory.sh/docs/kratos/self-service/flows/account-recovery-password-reset) - [Kratos Bring Your Own UI - Integration Basics](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-basic-integration)great-crayon-86888
02/14/2024, 9:33 AMchilly-king-10285
02/14/2024, 9:33 AMchilly-king-10285
02/14/2024, 9:33 AMgreat-crayon-86888
02/14/2024, 9:33 AMchilly-king-10285
02/14/2024, 9:33 AMchilly-king-10285
02/14/2024, 9:33 AMgreat-crayon-86888
02/14/2024, 9:38 AMchilly-king-10285
02/14/2024, 9:38 AMchilly-king-10285
02/14/2024, 9:38 AM