keycloaktotp

Get TOTP status from profile at Keycloak


How can I get TOTP status (set or not) for user profile using keycloak-js or API?

Tried:

keycloak.loadUserProfile().then(x => {...}) // there is no any info about totp
keycloak.loadUserInfo().then(x => {...}) // there is no any info about totp

Using Admin Rest API

GET "/admin/realms/{realm}/users/{userId}"

There is no any info as well


Solution

  • Use Admin REST API https://www.keycloak.org/docs-api/15.0/rest-api/index.html:

    GET /{realm}/users/{id}/credentials
    

    If some object from the response array is type: otp (not only type: password), then you can be sure, that user has configured OTP.