Edits history of script submission #22604 for ' List User Factors (okta)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * List User Factors
     * List the MFA factors enrolled for a user (e.g. Okta Verify, SMS, email, WebAuthn).
     */
    export async function main(auth: RT.Okta, user_id: string) {
      const url = new URL(
        `${auth.org_url}/api/v1/users/${encodeURIComponent(user_id)}/factors`
      )
    
      const response = await fetch(url, {
        method: "GET",
        headers: {
          Authorization: `SSWS ${auth.token}`,
          Accept: "application/json",
        },
      })
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 5 days ago