wooden-monitor-66999
09/22/2022, 1:35 AM/self-service/login/api
and subsequently the /self-service/login
to authenticate - in this case, since no aal
query parameter, a second challenge isn't provided.
However, when I call /self-service/login/api&aal=aal2
I get the following error:
{
"error": {
"id": "session_aal1_required",
"code": 401,
"status": "Unauthorized",
"request": "f75f7d03-5d53-92fa-a8d0-SCRUBBED,
"reason": "You can not requested a higher AAL (AAL2/AAL3) without an active session.",
"message": "aal2 and aal3 can only be requested if a session exists already"
}
}
How do I invoke/trigger the 2FA via apis? AFAI can tell from the docs, the use of self-service APIs requires the flow
which is retrieved by invoking the .../api
endpoint... and if .../api
requires aal
as Query parameter, how does one ever get a session first?
Appreciate any thoughts & guidance. Thanks!magnificent-energy-493
wooden-monitor-66999
09/22/2022, 12:17 PMbulky-guitar-23324
09/29/2022, 2:19 PMjson
...
"authentication_methods": [
{
"method": "password",
"aal": "aal1",
"completed_at": "2022-09-28T21:53:17.7964093Z"
}
...
2. Start 2nd flow with: /self-service/login/api&aal=aal2
- be sure to send the session token from first flow in header
- X-Session-Token: WbD0IgkwJmu1mYZicNhROvH1La8Yrw0Q
- along with 2fa in body, e.g:
POST /self-service/login?flow=a631ed7e-42ca-42d8-9f31-1eb57d91c98d HTTP/1.1
Host: 127.0.0.1:4434
User-Agent: OpenAPI-Generator/1.0.0/go
Content-Length: 39
Accept: application/json
Content-Type: application/json
X-Session-Token: WbD0IgkwJmu1mYZicNhROvH1La8Yrw0Q
Accept-Encoding: gzip
{"method":"totp","totp_code":"478360"}
- then you will have a session with aal2
json
GET /sessions/whoami HTTP/1.1
Host: 127.0.0.1:4434
User-Agent: OpenAPI-Generator/1.0.0/go
Accept: application/json
X-Session-Token: WbD0IgkwJmu1mYZicNhROvH1La8Yrw0Q
Accept-Encoding: gzip
HTTP/1.1 200 OK
Content-Length: 1220
Cache-Control: private, no-cache, no-store, must-revalidate
Content-Type: application/json; charset=utf-8
Date: Thu, 29 Sep 2022 02:47:01 GMT
Vary: Origin
Vary: Cookie
X-Kratos-Authenticated-Identity-Id: 0ef6ac4e-cc63-47a1-b6d9-4f2eb5f58630
...
"authentication_methods": [
{
"method": "password",
"aal": "aal1",
"completed_at": "2022-09-28T20:55:57.7402272Z"
},
{
"method": "totp",
"aal": "aal2",
"completed_at": "2022-09-28T20:55:57.8174699Z"
}
],
...