• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Obtaining Supported Authentication Capabilities
2
3<!--Kit: User Authentication Kit-->
4<!--Subsystem: UserIAM-->
5<!--Owner: @WALL_EYE-->
6<!--SE: @lichangting518-->
7<!--TSE: @jane_lz-->
8
9Different devices support different authentication capabilities (facial authentication, fingerprint authentication, and password authentication). Before you start coding, obtain the authentication capabilities supported by the target device.
10
11## Available APIs
12
13For details about the parameters, return value, and error codes, see [getAvailableStatus](../../reference/apis-user-authentication-kit/js-apis-useriam-userauth.md#userauthgetavailablestatus9).
14
15| API| Description|
16| -------- | -------- |
17| getAvailableStatus(authType : UserAuthType, authTrustLevel : AuthTrustLevel): void | Checks whether the specified authentication type and authentication trust level are supported by the device.|
18
19## How to Develop
20
211. [Request](prerequisites.md#requesting-permissions) the ohos.permission.ACCESS_BIOMETRIC permission.
22
232. Call [getAvailableStatus](../../reference/apis-user-authentication-kit/js-apis-useriam-userauth.md#userauthgetavailablestatus9) to check whether the device supports the specified authentication type ([UserAuthType](../../reference/apis-user-authentication-kit/js-apis-useriam-userauth.md#userauthtype8)) and authentication trust level ([AuthTrustLevel](../../reference/apis-user-authentication-kit/js-apis-useriam-userauth.md#authtrustlevel8)).
24
25   For details about the authentication trust levels, see [Principles for Classifying Biometric Authentication Trust Levels](../../security/UserAuthenticationKit/user-authentication-overview.md).
26
27Example: Check whether the device supports facial authentication of ATL3 or higher.
28
29```ts
30import { BusinessError } from  '@kit.BasicServicesKit';
31import { userAuth } from '@kit.UserAuthenticationKit';
32
33// Check whether the specified authentication capabilities are supported.
34try {
35    userAuth.getAvailableStatus(userAuth.UserAuthType.FACE, userAuth.AuthTrustLevel.ATL3);
36    console.info('current auth trust level is supported');
37} catch (error) {
38    const err: BusinessError = error as BusinessError;
39    console.error(`current auth trust level is not supported. Code is ${err?.code}, message is ${err?.message}`);
40}
41```
42