gray-library-49237
06/01/2024, 10:19 PMtime=2024-06-01T21:10:26Z level=error msg=An error occurred and is being forwarded to the error user interface. audience=application error=map[debug: message:The request was malformed or contained invalid parameters reason:AAL2 login via code requires the `via` query parameter stack_trace:
chilly-king-10285
06/01/2024, 10:19 PMchilly-king-10285
06/01/2024, 10:20 PMvia
query parameter is missing when trying to perform an AAL2 login via code. This parameter is used to specify which trait to use for delivering the code to the user. To resolve this error, you need to include the via
parameter in your request and set it to the identifier of the trait you want to use for delivering the code. For example, if you have a trait called phone_number
, you'd set via
to phone_number
. Here's an example of how you might structure your request: /self-service/login/browser?aal=aal2&via=phone_number
In this example, aal=aal2
initiates a new login flow for an already existing session with a higher level of authentication (AAL2), and via=phone_number
specifies that the code should be delivered to the user's phone number. Please ensure that the trait you're using with the via
parameter exists in your identity schema and is not empty in the current identity. If the trait does not exist or is empty, Ory will return an error. For more information, you can refer to the [Ory documentation on MFA via SMS](https://www.ory.sh/docs/kratos/mfa/mfa-via-sms#integration).gray-library-49237
06/01/2024, 11:50 PMory
.createBrowserLoginFlow({
refresh: Boolean(refresh),
aal: aal ? String(aal) : undefined,
returnTo: returnTo ? String(returnTo) : undefined,
})
.then(({ data }) => {
setFlow(data)
})
.catch(handleFlowError(router, "login", setFlow))
chilly-king-10285
06/01/2024, 11:51 PMchilly-king-10285
06/01/2024, 11:51 PMvia
parameter is indeed not mentioned. This parameter is used when you want to initiate a multi-factor authentication (MFA) flow, specifically an AAL2 flow, where you need to specify the trait to use for delivering the code to the user. If you want to include the via
parameter in your request, you can modify your createBrowserLoginFlow
function call to include it. Here's how you might do it: javascript ory .createBrowserLoginFlow({ refresh: Boolean(refresh), aal: aal ? String(aal) : undefined, returnTo: returnTo ? String(returnTo) : undefined, via: 'phone_number', // Add this line }) .then(({ data }) => { setFlow(data) }) .catch(handleFlowError(router, "login", setFlow))
In this example, via: 'phone_number'
is added to the request. This means that the code for the AAL2 login will be sent to the user's phone number. Please replace 'phone_number'
with the actual trait you have in your identity schema for delivering the code. Remember, the trait you're using with the via
parameter should exist in your identity schema and should not be empty in the current identity. If the trait does not exist or is empty, Ory will return an error. For more information, you can refer to the [Ory documentation on MFA via SMS](https://www.ory.sh/docs/kratos/mfa/mfa-via-sms#integration).gray-library-49237
06/02/2024, 12:18 AMchilly-king-10285
06/02/2024, 12:18 AMchilly-king-10285
06/02/2024, 12:18 AMgray-library-49237
06/02/2024, 1:27 AMchilly-king-10285
06/02/2024, 1:27 AMchilly-king-10285
06/02/2024, 1:27 AM