List the MFA factors enrolled for a user.
1
//native
2
3
/**
4
* List User Factors
5
* List the MFA factors enrolled for a user (e.g. Okta Verify, SMS, email, WebAuthn).
6
*/
7
export async function main(auth: RT.Okta, user_id: string) {
8
const url = new URL(
9
`${auth.org_url}/api/v1/users/${encodeURIComponent(user_id)}/factors`
10
)
11
12
const response = await fetch(url, {
13
method: "GET",
14
headers: {
15
Authorization: `SSWS ${auth.token}`,
16
Accept: "application/json",
17
},
18
})
19
20
if (!response.ok) {
21
throw new Error(`${response.status} ${await response.text()}`)
22
}
23
24
return await response.json()
25
26