1# @ohos.account.osAccount (System Account) (System API)
2
3The **osAccount** module provides basic capabilities for managing system (OS) accounts, including adding, deleting, querying, setting, subscribing to, and enabling a system account.
4
5> **NOTE**
6>
7> - The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.
8> - This topic describes only the system APIs provided by the module. For details about its public APIs, see [ohos.account.osAccount (System Account Management)](js-apis-osAccount.md).
9
10## Modules to Import
11
12```ts
13import { osAccount } from '@kit.BasicServicesKit';
14```
15
16## AccountManager
17
18Provides APIs for managing system accounts.
19
20### activateOsAccount
21
22activateOsAccount(localId: number, callback: AsyncCallback<void>): void
23
24Activates a system account. This API uses an asynchronous callback to return the result.
25
26**System API**: This is a system API.
27
28**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
29
30**System capability**: SystemCapability.Account.OsAccount
31
32**Parameters**
33
34| Name  | Type                      | Mandatory| Description                                               |
35| -------- | ------------------------- | ---- | -------------------------------------------------- |
36| localId  | number                    | Yes  | ID of the target system account.                 |
37| callback | AsyncCallback<void> | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
38
39**Error codes**
40
41| ID| Error Message            |
42| -------- | ------------------- |
43| 201 | Permission denied.|
44| 202 | Not system application.|
45| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
46| 12300001 | The system service works abnormally. |
47| 12300002 | Invalid localId.    |
48| 12300003 | Account not found. |
49| 12300008 | Restricted Account. |
50| 12300016 | The number of logged in accounts reaches the upper limit. |
51
52**Example**: Activate system account 100.
53  ```ts
54  import { BusinessError } from '@kit.BasicServicesKit';
55  let localId: number = 100;
56  try {
57    accountManager.activateOsAccount(localId, (err: BusinessError)=>{
58      if (err) {
59        console.error(`activateOsAccount failed, code is ${err.code}, message is ${err.message}`);
60      } else {
61        console.log('activateOsAccount successfully');
62      }
63    });
64  } catch (err) {
65    console.log('activateOsAccount failed, error:' + JSON.stringify(err));
66  }
67  ```
68
69### activateOsAccount
70
71activateOsAccount(localId: number): Promise<void>
72
73Activates a system account. This API uses a promise to return the result.
74
75**System API**: This is a system API.
76
77**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
78
79**System capability**: SystemCapability.Account.OsAccount
80
81**Parameters**
82
83| Name | Type  | Mandatory| Description                |
84| ------- | ------ | ---- | -------------------- |
85| localId | number | Yes  | ID of the target system account.|
86
87**Return value**
88
89| Type               | Description                                 |
90| ------------------- | ------------------------------------ |
91| Promise<void> | Promise that returns no value.|
92
93**Error codes**
94
95| ID| Error Message            |
96| -------- | ------------------- |
97| 201 | Permission denied.|
98| 202 | Not system application.|
99| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
100| 12300001 | The system service works abnormally. |
101| 12300002 | Invalid localId.    |
102| 12300003 | Account not found. |
103| 12300008 | Restricted Account. |
104| 12300016 | The number of logged in accounts reaches the upper limit. |
105
106**Example**: Activate system account 100.
107  ```ts
108  import { BusinessError } from '@kit.BasicServicesKit';
109  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
110  let localId: number = 100;
111  try {
112    accountManager.activateOsAccount(localId).then(() => {
113      console.log('activateOsAccount successfully');
114    }).catch((err: BusinessError) => {
115      console.log('activateOsAccount failed, err:' + JSON.stringify(err));
116    });
117  } catch (e) {
118    console.log('activateOsAccount exception: ' + JSON.stringify(e));
119  }
120  ```
121
122### deactivateOsAccount<sup>12+</sup>
123
124deactivateOsAccount(localId: number): Promise&lt;void&gt;
125
126Deactivates (logs out of) a system account. This API uses a promise to return the result.
127
128**System API**: This is a system API.
129
130**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
131
132**System capability**: SystemCapability.Account.OsAccount
133
134**Parameters**
135
136| Name | Type  | Mandatory| Description                |
137| ------- | ------ | ---- | -------------------- |
138| localId | number | Yes  | ID of the target system account.|
139
140**Return value**
141
142| Type               | Description                                 |
143| ------------------- | ------------------------------------ |
144| Promise&lt;void&gt; | Promise that returns no value.|
145
146**Error codes**
147
148| ID| Error Message            |
149| -------- | ------------------- |
150| 201 | Permission denied.|
151| 202 | Not system application.|
152| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
153| 12300001 | The system service works abnormally. |
154| 12300003 | Account not found. |
155| 12300008 | Restricted Account. |
156
157**Example**: Deactivate system account 100.
158  ```ts
159  import { BusinessError } from '@kit.BasicServicesKit';
160  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
161  let localId: number = 100;
162  try {
163    accountManager.deactivateOsAccount(localId).then(() => {
164      console.log('deactivateOsAccount successfully');
165    }).catch((err: BusinessError) => {
166      console.log('deactivateOsAccount failed, err:' + JSON.stringify(err));
167    });
168  } catch (e) {
169    console.log('deactivateOsAccount exception: ' + JSON.stringify(e));
170  }
171  ```
172
173### isOsAccountActivated<sup>11+</sup>
174
175isOsAccountActivated(localId: number): Promise&lt;boolean&gt;
176
177Checks whether a system account is activated. This API uses a promise to return the result.
178
179**System API**: This is a system API.
180
181**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
182
183**System capability**: SystemCapability.Account.OsAccount
184
185**Parameters**
186
187| Name | Type  | Mandatory| Description                              |
188| ------- | ------ | ---- | --------------------------------- |
189| localId | number | Yes  | ID of the target system account.|
190
191**Return value**
192
193| Type                  | Description                                                      |
194| ---------------------- | ---------------------------------------------------------- |
195| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the account is activated; the value **false** means the opposite.|
196
197**Error codes**
198
199| ID| Error Message            |
200| -------- | ------------------- |
201| 201 | Permission denied.|
202| 202 | Not system application.|
203| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
204| 12300001 | The system service works abnormally. |
205| 12300003 | Account not found. |
206
207**Example**: Check whether system account 100 is activated.
208
209  ```ts
210  import { BusinessError } from '@kit.BasicServicesKit';
211  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
212  let localId: number = 100;
213  try {
214    accountManager.isOsAccountActivated(localId).then((isActivated: boolean) => {
215      console.log('isOsAccountActivated successfully, isActivated: ' + isActivated);
216    }).catch((err: BusinessError) => {
217      console.log('isOsAccountActivated failed, error: ' + JSON.stringify(err));
218    });
219  } catch (err) {
220    console.log('isOsAccountActivated exception: ' + JSON.stringify(err));
221  }
222  ```
223
224### isOsAccountConstraintEnabled<sup>11+</sup>
225
226isOsAccountConstraintEnabled(localId: number, constraint: string): Promise&lt;boolean&gt;
227
228Checks whether a constraint is enabled for a system account. This API uses a promise to return the result.
229
230**System API**: This is a system API.
231
232**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
233
234**System capability**: SystemCapability.Account.OsAccount
235
236**Parameters**
237
238| Name    | Type  | Mandatory| Description                               |
239| ---------- | ------ | ---- | ---------------------------------- |
240| localId    | number | Yes  | ID of the target system account. |
241| constraint | string | Yes  | [Constraint](js-apis-osAccount.md#constraints) to check.|
242
243**Return value**
244
245| Type                  | Description                                                                 |
246| --------------------- | --------------------------------------------------------------------- |
247| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the specified constraint is enabled; the value **false** means the opposite.|
248
249**Error codes**
250
251| ID| Error Message            |
252| -------- | ------------------- |
253| 201 | Permission denied.|
254| 202 | Not system application.|
255| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
256| 12300001 | The system service works abnormally. |
257| 12300003 | Account not found. |
258
259**Example**: Check whether system account 100 is forbidden to use Wi-Fi.
260
261  ```ts
262  import { BusinessError } from '@kit.BasicServicesKit';
263  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
264  let localId: number = 100;
265  let constraint: string = 'constraint.wifi';
266  try {
267    accountManager.isOsAccountConstraintEnabled(localId, constraint).then((isEnabled: boolean) => {
268      console.log('isOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
269    }).catch((err: BusinessError) => {
270      console.log('isOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err));
271    });
272  } catch (err) {
273    console.log('isOsAccountConstraintEnabled exception: ' + JSON.stringify(err));
274  }
275  ```
276
277### isOsAccountUnlocked<sup>11+</sup>
278
279isOsAccountUnlocked(localId: number): Promise&lt;boolean&gt;
280
281Checks whether a system account has been verified. This API uses a promise to return the result.
282
283**System API**: This is a system API.
284
285**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
286
287**System capability**: SystemCapability.Account.OsAccount
288
289**Parameters**
290
291| Name | Type  | Mandatory| Description                                                             |
292| ------- | ------ | ---- | --------------------------------------------------------------- |
293| localId | number | Yes  | ID of the target system account. If this parameter is not specified, this API checks whether the current system account has been verified.|
294
295**Return value**
296
297| Type                  | Description                                                              |
298| ---------------------- | ----------------------------------------------------------------- |
299| Promise&lt;boolean&gt; | Promise used to return the result. The value **true** means the system account has been verified; the value **false** means the opposite.|
300
301**Error codes**
302
303| ID| Error Message            |
304| -------- | ------------------- |
305| 201 | Permission denied.|
306| 202 | Not system application.|
307| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
308| 12300001 | The system service works abnormally. |
309| 12300003 | Account not found. |
310
311**Example**
312
313  ```ts
314  import { BusinessError } from '@kit.BasicServicesKit';
315  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
316  let localId: number = 100;
317  try {
318    accountManager.isOsAccountUnlocked(localId).then((isVerified: boolean) => {
319      console.log('isOsAccountUnlocked successfully, isVerified: ' + isVerified);
320    }).catch((err: BusinessError) => {
321      console.log('isOsAccountUnlocked failed, error: ' + JSON.stringify(err));
322    });
323  } catch (err) {
324    console.log('isOsAccountUnlocked exception: ' + JSON.stringify(err));
325  }
326  ```
327
328### removeOsAccount
329
330removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
331
332Removes a system account. This API uses an asynchronous callback to return the result.
333
334**System API**: This is a system API.
335
336**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
337
338**System capability**: SystemCapability.Account.OsAccount
339
340**Parameters**
341
342| Name  | Type                     | Mandatory| Description                                                |
343| -------- | ------------------------- | ---- | -------------------------------------------------- |
344| localId  | number                    | Yes  | ID of the target system account.                 |
345| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
346
347**Error codes**
348
349| ID| Error Message            |
350| -------- | ------------------- |
351| 201 | Permission denied.|
352| 202 | Not system application.|
353| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
354| 12300001 | The system service works abnormally. |
355| 12300002 | Invalid localId.    |
356| 12300003 | Account not found. |
357| 12300008 | Restricted Account. |
358
359**Example**
360
361  ```ts
362  import { BusinessError } from '@kit.BasicServicesKit';
363  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
364  let accountName: string = 'testAccountName';
365  try {
366    accountManager.createOsAccount(accountName, osAccount.OsAccountType.NORMAL,
367      (err: BusinessError, osAccountInfo: osAccount.OsAccountInfo) => {
368        accountManager.removeOsAccount(osAccountInfo.localId, (err: BusinessError)=>{
369          if (err) {
370            console.log('removeOsAccount failed, error: ' + JSON.stringify(err));
371          } else {
372            console.log('removeOsAccount successfully');
373          }
374      });
375    });
376  } catch (err) {
377    console.log('removeOsAccount exception: ' + JSON.stringify(err));
378  }
379  ```
380
381### removeOsAccount
382
383removeOsAccount(localId: number): Promise&lt;void&gt;
384
385Removes a system account. This API uses a promise to return the result.
386
387**System API**: This is a system API.
388
389**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
390
391**System capability**: SystemCapability.Account.OsAccount
392
393**Parameters**
394
395| Name | Type  | Mandatory| Description                              |
396| ------- | ------ | ---- | --------------------------------- |
397| localId | number | Yes  | ID of the target system account.|
398
399**Return value**
400
401| Type               | Description                                 |
402| ------------------- | ------------------------------------ |
403| Promise&lt;void&gt; | Promise that returns no value.|
404
405**Error codes**
406
407| ID| Error Message            |
408| -------- | ------------------- |
409| 201 | Permission denied.|
410| 202 | Not system application.|
411| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
412| 12300001 | The system service works abnormally. |
413| 12300002 | Invalid localId.    |
414| 12300003 | Account not found. |
415| 12300008 | Restricted Account. |
416
417**Example**
418
419  ```ts
420  import { BusinessError } from '@kit.BasicServicesKit';
421  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
422  let accountName: string = 'testAccountName';
423  try {
424    accountManager.createOsAccount(accountName, osAccount.OsAccountType.NORMAL,
425      (err: BusinessError, osAccountInfo: osAccount.OsAccountInfo)=>{
426        accountManager.removeOsAccount(osAccountInfo.localId).then(() => {
427          console.log('removeOsAccount successfully');
428        }).catch((err: BusinessError) => {
429            console.log('removeOsAccount failed, error: ' + JSON.stringify(err));
430        });
431    });
432  } catch (err) {
433    console.log('removeOsAccount exception: ' + JSON.stringify(err));
434  }
435  ```
436
437### setOsAccountConstraints
438
439setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean,callback: AsyncCallback&lt;void&gt;): void
440
441Sets or removes constraints for a system account. This API uses an asynchronous callback to return the result.
442
443**System API**: This is a system API.
444
445**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
446
447**System capability**: SystemCapability.Account.OsAccount
448
449**Parameters**
450
451| Name     | Type                     | Mandatory| Description                                            |
452| ----------- | ------------------------- | ---- | ----------------------------------------------- |
453| localId     | number                    | Yes  | ID of the target system account.              |
454| constraints | Array&lt;string&gt;       | Yes  | [Constraints](js-apis-osAccount.md#constraints) to set or remove.       |
455| enable      | boolean                   | Yes  | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints.                          |
456| callback    | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
457
458**Error codes**
459
460| ID| Error Message            |
461| -------- | ------------------- |
462| 201 | Permission denied.|
463| 202 | Not system application.|
464| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
465| 12300001 | The system service works abnormally. |
466| 12300002 | Invalid localId or constraints.    |
467| 12300003 | Account not found. |
468| 12300008 | Restricted Account. |
469
470**Example**: Disable Wi-Fi for system account 100.
471
472  ```ts
473  import { BusinessError } from '@kit.BasicServicesKit';
474  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
475  let localId: number = 100;
476  let constraint: string = 'constraint.wifi';
477  try {
478    accountManager.setOsAccountConstraints(localId, [constraint], true, (err: BusinessError) => {
479      if (err) {
480        console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
481      } else {
482        console.log('setOsAccountConstraints successfully');
483      }
484    });
485  } catch (err) {
486    console.log('setOsAccountConstraints exception: ' + JSON.stringify(err));
487  }
488  ```
489
490### setOsAccountConstraints
491
492setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean): Promise&lt;void&gt;
493
494Sets or removes constraints for a system account. This API uses a promise to return the result.
495
496**System API**: This is a system API.
497
498**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
499
500**System capability**: SystemCapability.Account.OsAccount
501
502**Parameters**
503
504| Name     | Type               | Mandatory| Description                                        |
505| ----------- | ------------------- | ---- | -------------------------------------------- |
506| localId     | number              | Yes  | ID of the target system account.          |
507| constraints | Array&lt;string&gt; | Yes  | [Constraints](js-apis-osAccount.md#constraints) to set or remove.   |
508| enable      | boolean             | Yes  | Set or remove constraints. The value **true** means to set constraints, and **false** means to remove constraints.                    |
509
510**Return value**
511
512| Type               | Description                                |
513| :------------------ | :----------------------------------- |
514| Promise&lt;void&gt; | Promise that returns no value.|
515
516**Error codes**
517
518| ID| Error Message            |
519| -------- | ------------------- |
520| 201 | Permission denied.|
521| 202 | Not system application.|
522| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
523| 12300001 | The system service works abnormally. |
524| 12300002 | Invalid localId or constraints.    |
525| 12300003 | Account not found. |
526| 12300008 | Restricted Account. |
527
528**Example**: Remove the constraint on the use of Wi-Fi for system account 100.
529
530  ```ts
531  import { BusinessError } from '@kit.BasicServicesKit';
532  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
533  let localId: number = 100;
534  try {
535    accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => {
536      console.log('setOsAccountConstraints succsuccessfully');
537    }).catch((err: BusinessError) => {
538      console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
539    });
540  } catch (err) {
541    console.log('setOsAccountConstraints exception: ' + JSON.stringify(err));
542  }
543  ```
544
545### setOsAccountName
546
547setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt;void&gt;): void
548
549Sets the name of a system account. This API uses an asynchronous callback to return the result.
550
551**System API**: This is a system API.
552
553**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
554
555**System capability**: SystemCapability.Account.OsAccount
556
557**Parameters**
558
559| Name   | Type                     | Mandatory| Description                                            |
560| :-------- | ------------------------- | ---- | ----------------------------------------------- |
561| localId   | number                    | Yes  | ID of the target system account.              |
562| localName | string                    | Yes  | Account name to set. The value cannot exceed 1024 characters.                         |
563| callback  | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
564
565**Error codes**
566
567| ID| Error Message            |
568| -------- | ------------------- |
569| 201 | Permission denied.|
570| 202 | Not system application.|
571| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
572| 12300001 | The system service works abnormally. |
573| 12300002 | Invalid localId or localName. |
574| 12300003 | Account not found. |
575| 12300008 | Restricted Account. |
576
577**Example**: Set the name of system account 100 to **demoName**.
578
579  ```ts
580  import { BusinessError } from '@kit.BasicServicesKit';
581  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
582  let localId: number = 100;
583  let name: string = 'demoName';
584  try {
585    accountManager.setOsAccountName(localId, name, (err: BusinessError) => {
586      if (err) {
587        console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
588      } else {
589        console.log('setOsAccountName successfully');
590      }
591    });
592  } catch (err) {
593    console.log('setOsAccountName exception: ' + JSON.stringify(err));
594  }
595  ```
596
597### setOsAccountName
598
599setOsAccountName(localId: number, localName: string): Promise&lt;void&gt;
600
601Sets the name of a system account. This API uses a promise to return the result.
602
603**System API**: This is a system API.
604
605**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
606
607**System capability**: SystemCapability.Account.OsAccount
608
609**Parameters**
610
611| Name   | Type  | Mandatory| Description                               |
612| --------- | ------ | ---- | --------------------------------- |
613| localId   | number | Yes  | ID of the target system account.|
614| localName | string | Yes  | Account name to set. The value cannot exceed 1024 characters.           |
615
616**Return value**
617
618| Type               | Description                                 |
619| ------------------- | ------------------------------------ |
620| Promise&lt;void&gt; | Promise that returns no value.|
621
622**Error codes**
623
624| ID| Error Message            |
625| -------- | ------------------- |
626| 201 | Permission denied.|
627| 202 | Not system application.|
628| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
629| 12300001 | The system service works abnormally. |
630| 12300002 | Invalid localId or localName.    |
631| 12300003 | Account not found. |
632| 12300008 | Restricted Account. |
633
634**Example**: Set the name of system account 100 to **demoName**.
635
636  ```ts
637  import { BusinessError } from '@kit.BasicServicesKit';
638  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
639  let localId: number = 100;
640  let name: string = 'testName';
641  try {
642    accountManager.setOsAccountName(localId, name).then(() => {
643      console.log('setOsAccountName successfully');
644    }).catch((err: BusinessError) => {
645      console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
646    });
647  } catch (err) {
648    console.log('setOsAccountName exception: ' + JSON.stringify(err));
649  }
650  ```
651
652### queryMaxOsAccountNumber
653
654queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void
655
656Queries the maximum number of system accounts that can be created. This API uses an asynchronous callback to return the result.
657
658**System API**: This is a system API.
659
660**System capability**: SystemCapability.Account.OsAccount
661
662**Parameters**
663
664| Name  | Type                       | Mandatory| Description                                                                             |
665| -------- | --------------------------- | ---- | -------------------------------------------------------------------------------- |
666| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the maximum number of system accounts that can be created. Otherwise, **err** is an error object.|
667
668**Error codes**
669
670| ID| Error Message      |
671| -------- | ------------- |
672| 202 | Not system application.|
673| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
674| 12300001 | The system service works abnormally. |
675
676**Example**
677
678  ```ts
679  import { BusinessError } from '@kit.BasicServicesKit';
680  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
681  try {
682    accountManager.queryMaxOsAccountNumber((err: BusinessError, maxCnt: number) => {
683      if (err) {
684        console.log('queryMaxOsAccountNumber failed, error:' + JSON.stringify(err));
685      } else {
686        console.log('queryMaxOsAccountNumber successfully, maxCnt:' + maxCnt);
687      }
688    });
689  } catch (err) {
690    console.log('queryMaxOsAccountNumber exception: ' + JSON.stringify(err));
691  }
692  ```
693
694### queryMaxOsAccountNumber
695
696queryMaxOsAccountNumber(): Promise&lt;number&gt;
697
698Queries the maximum number of system accounts that can be created. This API uses a promise to return the result.
699
700**System API**: This is a system API.
701
702**System capability**: SystemCapability.Account.OsAccount
703
704**Return value**
705
706| Type                 | Description                                        |
707| --------------------- | ------------------------------------------- |
708| Promise&lt;number&gt; | Promise used to return the maximum number of system accounts that can be created.|
709
710**Error codes**
711
712| ID| Error Message      |
713| -------- | ------------- |
714| 202 | Not system application.|
715| 12300001 | The system service works abnormally. |
716
717**Example**
718
719  ```ts
720  import { BusinessError } from '@kit.BasicServicesKit';
721  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
722  try {
723    accountManager.queryMaxOsAccountNumber().then((maxCnt: number) => {
724      console.log('queryMaxOsAccountNumber successfully, maxCnt: ' + maxCnt);
725    }).catch((err: BusinessError) => {
726      console.log('queryMaxOsAccountNumber failed, error: ' + JSON.stringify(err));
727    });
728  } catch (err) {
729    console.log('queryMaxOsAccountNumber exception: ' + JSON.stringify(err));
730  }
731  ```
732
733### queryMaxLoggedInOsAccountNumber<sup>12+</sup>
734
735queryMaxLoggedInOsAccountNumber(): Promise&lt;number&gt;
736
737Queries the maximum number of system accounts allowed to log in to the system. This API uses a promise to return the result.
738
739**System API**: This is a system API.
740
741**System capability**: SystemCapability.Account.OsAccount
742
743**Return value**
744
745| Type                 | Description                                        |
746| --------------------- | ------------------------------------------- |
747| Promise&lt;number&gt; | Promise used to return the result.|
748
749**Error codes**
750
751| ID| Error Message      |
752| -------- | ------------- |
753| 202 | Not system application.|
754| 12300001 | The system service works abnormally. |
755
756**Example**
757
758  ```ts
759  import { BusinessError } from '@kit.BasicServicesKit';
760  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
761  try {
762    accountManager.queryMaxLoggedInOsAccountNumber().then((maxNum: number) => {
763      console.log('queryMaxLoggedInOsAccountNumber successfully, maxNum: ' + maxNum);
764    }).catch((err: BusinessError) => {
765      console.log('queryMaxLoggedInOsAccountNumber failed, error: ' + JSON.stringify(err));
766    });
767  } catch (err) {
768    console.log('queryMaxLoggedInOsAccountNumber exception: ' + JSON.stringify(err));
769  }
770  ```
771
772### getEnabledOsAccountConstraints<sup>11+</sup>
773
774getEnabledOsAccountConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
775
776Obtains all the enabled constraints of a system account. This API uses a promise to return the result.
777
778**System API**: This is a system API.
779
780**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
781
782**System capability**: SystemCapability.Account.OsAccount
783
784**Parameters**
785
786| Name | Type  | Mandatory| Description        |
787| ------- | ------ | ---- | ------------ |
788| localId | number | Yes  | ID of the target system account.|
789
790**Return value**
791
792| Type                              | Description                                                      |
793| ---------------------------------- | ---------------------------------------------------------- |
794| Promise&lt;Array&lt;string&gt;&gt; | Promise used to return all the enabled [constraints](js-apis-osAccount.md#constraints) of the system account.|
795
796**Error codes**
797
798| ID| Error Message            |
799| -------- | ------------------- |
800| 201 | Permission denied.|
801| 202 | Not system application.|
802| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
803| 12300001 | The system service works abnormally. |
804| 12300003 | Account not found. |
805
806**Example**: Obtain all constraints of system account 100.
807
808  ```ts
809  import { BusinessError } from '@kit.BasicServicesKit';
810  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
811  let localId: number = 100;
812  try {
813    accountManager.getEnabledOsAccountConstraints(localId).then((constraints: string[]) => {
814      console.log('getEnabledOsAccountConstraints, constraints: ' + constraints);
815    }).catch((err: BusinessError) => {
816      console.log('getEnabledOsAccountConstraints err: ' + JSON.stringify(err));
817    });
818  } catch (e) {
819    console.log('getEnabledOsAccountConstraints exception: ' + JSON.stringify(e));
820  }
821  ```
822
823### queryAllCreatedOsAccounts
824
825queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;&gt;): void
826
827Queries information about all the system accounts created. This API uses an asynchronous callback to return the result.
828
829**System API**: This is a system API.
830
831**System capability**: SystemCapability.Account.OsAccount
832
833**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
834
835**Parameters**
836
837| Name  | Type                                                        | Mandatory| Description                                              |
838| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
839| callback | AsyncCallback&lt;Array&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt;&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is a list of all created system accounts. Otherwise, **data** is an error object.|
840
841**Error codes**
842
843| ID| Error Message      |
844| -------- | ------------- |
845| 201 | Permission denied.|
846| 202 | Not system application.|
847| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types.|
848| 12300001 | The system service works abnormally. |
849
850**Example**
851
852  ```ts
853  import { BusinessError } from '@kit.BasicServicesKit';
854  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
855  try {
856    accountManager.queryAllCreatedOsAccounts((err: BusinessError, accountArr: osAccount.OsAccountInfo[])=>{
857      console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err));
858      console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr));
859    });
860  } catch (e) {
861    console.log('queryAllCreatedOsAccounts exception: ' + JSON.stringify(e));
862  }
863  ```
864
865### queryAllCreatedOsAccounts
866
867queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;
868
869Queries information about all the system accounts created. This API uses a promise to return the result.
870
871**System API**: This is a system API.
872
873**System capability**: SystemCapability.Account.OsAccount
874
875**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
876
877**Return value**
878
879| Type                                                       | Description                                          |
880| ----------------------------------------------------------- | --------------------------------------------- |
881| Promise&lt;Array&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt;&gt; | Promise used to return the information about all the system accounts created.|
882
883**Error codes**
884
885| ID| Error Message      |
886| -------- | ------------- |
887| 201 | Permission denied.|
888| 202 | Not system application.|
889| 12300001 | The system service works abnormally. |
890
891**Example**
892
893  ```ts
894  import { BusinessError } from '@kit.BasicServicesKit';
895  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
896  try {
897    accountManager.queryAllCreatedOsAccounts().then((accountArr: osAccount.OsAccountInfo[]) => {
898      console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
899    }).catch((err: BusinessError) => {
900      console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err));
901    });
902  } catch (e) {
903    console.log('queryAllCreatedOsAccounts exception: ' + JSON.stringify(e));
904  }
905  ```
906
907### getForegroundOsAccountLocalId<sup>12+</sup>
908
909getForegroundOsAccountLocalId(): Promise&lt;number&gt;;
910
911Obtains the ID of the foreground system account.
912
913**System API**: This is a system API.
914
915**System capability**: SystemCapability.Account.OsAccount
916
917**Return value**
918
919| Type                  | Description                                                              |
920| ---------------------- | ----------------------------------------------------------------- |
921| Promise&lt;number&gt; | Promise used to return the result. return the ID of the foreground system account obtained.|
922
923**Error codes**
924
925| ID| Error Message      |
926| -------- | ------------- |
927| 202 | Not system application.|
928| 12300001 | The system service works abnormally. |
929
930**Example**
931
932  ```ts
933  import { BusinessError } from '@kit.BasicServicesKit';
934  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
935  try {
936    accountManager.getForegroundOsAccountLocalId().then((localId: number) => {
937      console.log('getForegroundOsAccountLocalId, localId: ' + localId);
938    }).catch((err: BusinessError) => {
939      console.log('getForegroundOsAccountLocalId err: ' + JSON.stringify(err));
940    });
941  } catch (e) {
942    console.log('getForegroundOsAccountLocalId exception: ' + JSON.stringify(e));
943  }
944  ```
945
946### createOsAccount
947
948createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
949
950Creates a system account. This API uses an asynchronous callback to return the result.
951
952**System API**: This is a system API.
953
954**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
955
956**System capability**: SystemCapability.Account.OsAccount
957
958**Parameters**
959
960| Name   | Type                                                | Mandatory| Description                                                                        |
961| :-------- | ---------------------------------------------------- | ---- | --------------------------------------------------------------------------- |
962| localName | string                                               | Yes  | Name of the system account to create.                                                       |
963| type      | [OsAccountType](js-apis-osAccount.md#osaccounttype)                      | Yes  | Type of the system account to create.                                                       |
964| callback  | AsyncCallback&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the created system account. Otherwise, **err** is an error object.|
965
966**Error codes**
967
968| ID | Error Message                  |
969| -------- | ------------------------- |
970| 201 | Permission denied.|
971| 202 | Not system application.|
972| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
973| 12300001 | The system service works abnormally. |
974| 12300002 | Invalid localName or type. |
975| 12300004 | Local name already exists. |
976| 12300005 | Multi-user not supported. |
977| 12300006 | Unsupported account type. |
978| 12300007 | The number of accounts has reached the upper limit. |
979
980**Example**
981
982  ```ts
983  import { BusinessError } from '@kit.BasicServicesKit';
984  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
985  try {
986    accountManager.createOsAccount('testName', osAccount.OsAccountType.NORMAL,
987      (err: BusinessError, osAccountInfo: osAccount.OsAccountInfo)=>{
988      console.log('createOsAccount err:' + JSON.stringify(err));
989      console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo));
990    });
991  } catch (e) {
992    console.log('createOsAccount exception: ' + JSON.stringify(e));
993  }
994  ```
995
996### createOsAccount
997
998createOsAccount(localName: string, type: OsAccountType, options?: CreateOsAccountOptions): Promise&lt;OsAccountInfo&gt;
999
1000Creates a system account. This API uses a promise to return the result.
1001
1002**System API**: This is a system API.
1003
1004**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1005
1006**System capability**: SystemCapability.Account.OsAccount
1007
1008**Parameters**
1009
1010| Name   | Type                           | Mandatory| Description                  |
1011| --------- | ------------------------------- | ---- | ---------------------- |
1012| localName | string                          | Yes  | Name of the system account to create.|
1013| type      | [OsAccountType](js-apis-osAccount.md#osaccounttype) | Yes  | Type of the system account to create.|
1014| options      | [CreateOsAccountOptions](js-apis-osAccount-sys.md#createosaccountoptions12) | No  | Options for creating a system account. By default, this parameter is left blank.<br>This parameter is supported since API version 12. |
1015
1016**Return value**
1017
1018| Type                                          | Description                                 |
1019| ---------------------------------------------- | ------------------------------------- |
1020| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise used to return the information about the created system account.|
1021
1022**Error codes**
1023
1024| ID | Error Message                  |
1025| -------- | ------------------------- |
1026| 201 | Permission denied.|
1027| 202 | Not system application.|
1028| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1029| 12300001 | The system service works abnormally. |
1030| 12300002 | Invalid localName, type or options. |
1031| 12300004 | Local name already exists. |
1032| 12300005 | Multi-user not supported. |
1033| 12300006 | Unsupported account type. |
1034| 12300007 | The number of accounts has reached the upper limit. |
1035| 12300015 | The short name already exists. |
1036
1037**Example**
1038
1039  ```ts
1040  import { BusinessError } from '@kit.BasicServicesKit';
1041  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1042  let options: osAccount.CreateOsAccountOptions = {
1043    shortName: 'myShortName'
1044  }
1045  try {
1046    accountManager.createOsAccount('testAccountName', osAccount.OsAccountType.NORMAL, options).then(
1047      (accountInfo: osAccount.OsAccountInfo) => {
1048      console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
1049    }).catch((err: BusinessError) => {
1050      console.log('createOsAccount err: ' + JSON.stringify(err));
1051    });
1052  } catch (e) {
1053    console.log('createOsAccount exception: ' + JSON.stringify(e));
1054  }
1055  ```
1056
1057### createOsAccountForDomain<sup>8+</sup>
1058
1059createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
1060
1061Creates a system account and associates it with the specified domain account. This API uses an asynchronous callback to return the result.
1062
1063**System API**: This is a system API.
1064
1065**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1066
1067**System capability**: SystemCapability.Account.OsAccount
1068
1069**Parameters**
1070
1071| Name    | Type                                                | Mandatory| Description                                                                        |
1072| ---------- | ---------------------------------------------------- | ---- | -------------------------------------------------------------------------- |
1073| type       | [OsAccountType](js-apis-osAccount.md#osaccounttype)                      | Yes  | Type of the system account to create.                                                      |
1074| domainInfo | [DomainAccountInfo](#domainaccountinfo8)              | Yes  | Domain account information.                                                              |
1075| callback   | AsyncCallback&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the created system account. Otherwise, **err** is an error object.|
1076
1077**Error codes**
1078
1079| ID| Error Message                    |
1080| -------- | ------------------- |
1081| 201 | Permission denied.|
1082| 202 | Not system application.|
1083| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1084| 801 | Capability not supported.|
1085| 12300001 | The system service works abnormally. |
1086| 12300002 | Invalid type or domainInfo. |
1087| 12300004 | Account already exists. |
1088| 12300005 | Multi-user not supported. |
1089| 12300006 | Unsupported account type. |
1090| 12300007 | The number of accounts has reached the upper limit. |
1091
1092**Example**
1093
1094  ```ts
1095  import { BusinessError } from '@kit.BasicServicesKit';
1096  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1097  let domainInfo: osAccount.DomainAccountInfo =
1098    {domain: 'testDomain', accountName: 'testAccountName'};
1099  try {
1100    accountManager.createOsAccountForDomain(osAccount.OsAccountType.NORMAL, domainInfo,
1101      (err: BusinessError, osAccountInfo: osAccount.OsAccountInfo)=>{
1102      console.log('createOsAccountForDomain err:' + JSON.stringify(err));
1103      console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo));
1104    });
1105  } catch (e) {
1106    console.log('createOsAccountForDomain exception: ' + JSON.stringify(e));
1107  }
1108  ```
1109
1110### createOsAccountForDomain<sup>8+</sup>
1111
1112createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, options?: CreateOsAccountForDomainOptions): Promise&lt;OsAccountInfo&gt;
1113
1114Creates a system account and associates it with the specified domain account. This API uses a promise to return the result.
1115
1116**System API**: This is a system API.
1117
1118**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1119
1120**System capability**: SystemCapability.Account.OsAccount
1121
1122**Parameters**
1123
1124| Name    | Type                                     | Mandatory| Description                |
1125| ---------- | ---------------------------------------- | ---- | -------------------- |
1126| type       | [OsAccountType](js-apis-osAccount.md#osaccounttype)          | Yes  | Type of the system account to create.|
1127| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | Yes  | Domain account information.         |
1128| options      | [CreateOsAccountForDomainOptions](#createosaccountfordomainoptions12) | No  | Optional parameters for creating the account. By default, this parameter is left blank.<br>This parameter is supported since API version 12. |
1129
1130**Return value**
1131
1132| Type                                          | Description                                   |
1133| ---------------------------------------------- | -------------------------------------- |
1134| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise used to return the information about the created system account.|
1135
1136**Error codes**
1137
1138| ID| Error Message                    |
1139| -------- | ------------------- |
1140| 201 | Permission denied.|
1141| 202 | Not system application.|
1142| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1143| 801 | Capability not supported.|
1144| 12300001 | The system service works abnormally. |
1145| 12300002 | Invalid type, domainInfo or options. |
1146| 12300004 | Account already exists. |
1147| 12300005 | Multi-user not supported. |
1148| 12300006 | Unsupported account type. |
1149| 12300007 | The number of accounts has reached the upper limit. |
1150| 12300015 | The short name already exists. |
1151
1152**Example**
1153
1154  ```ts
1155  import { BusinessError } from '@kit.BasicServicesKit';
1156  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1157  let domainInfo: osAccount.DomainAccountInfo =
1158    {domain: 'testDomain', accountName: 'testAccountName'};
1159  let options: osAccount.CreateOsAccountForDomainOptions = {
1160    shortName: 'myShortName'
1161  }
1162  try {
1163    accountManager.createOsAccountForDomain(osAccount.OsAccountType.NORMAL, domainInfo, options).then(
1164      (accountInfo: osAccount.OsAccountInfo) => {
1165      console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo));
1166    }).catch((err: BusinessError) => {
1167      console.log('createOsAccountForDomain err: ' + JSON.stringify(err));
1168    });
1169  } catch (e) {
1170    console.log('createOsAccountForDomain exception: ' + JSON.stringify(e));
1171  }
1172  ```
1173
1174### queryOsAccount<sup>11+</sup>
1175
1176queryOsAccount(): Promise&lt;OsAccountInfo&gt;
1177
1178Obtains information about the system account to which the current process belongs. This API uses a promise to return the result.
1179
1180**System API**: This is a system API.
1181
1182**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.GET_LOCAL_ACCOUNTS
1183
1184**System capability**: SystemCapability.Account.OsAccount
1185
1186**Return value**
1187
1188| Type                                          | Description                                      |
1189| ---------------------------------------------- | ----------------------------------------- |
1190| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise used to return the system account information obtained.|
1191
1192**Error codes**
1193
1194| ID| Error Message            |
1195| -------- | ------------------- |
1196| 201 | Permission denied.|
1197| 202 | Not system application.|
1198| 12300001 | The system service works abnormally. |
1199
1200**Example**
1201
1202  ```ts
1203  import { BusinessError } from '@kit.BasicServicesKit';
1204  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1205  try {
1206    accountManager.queryOsAccount().then((accountInfo: osAccount.OsAccountInfo) => {
1207      console.log('queryOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
1208    }).catch((err: BusinessError) => {
1209      console.log('queryOsAccount err: ' + JSON.stringify(err));
1210    });
1211  } catch (e) {
1212    console.log('queryOsAccount exception: ' + JSON.stringify(e));
1213  }
1214  ```
1215
1216### queryOsAccountById
1217
1218queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
1219
1220Queries information about the system account of the given ID. This API uses an asynchronous callback to return the result.
1221
1222**System API**: This is a system API.
1223
1224**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1225
1226**System capability**: SystemCapability.Account.OsAccount
1227
1228**Parameters**
1229
1230| Name  | Type                                                | Mandatory| Description                                                                      |
1231| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------------------ |
1232| localId  | number                                               | Yes  | ID of the target system account.                                                     |
1233| callback | AsyncCallback&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the system account information obtained. Otherwise, **data** is an error object.|
1234
1235**Error codes**
1236
1237| ID| Error Message            |
1238| -------- | ------------------- |
1239| 201 | Permission denied.|
1240| 202 | Not system application.|
1241| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1242| 12300001 | The system service works abnormally. |
1243| 12300002 | Invalid localId.    |
1244| 12300003 | Account not found. |
1245
1246**Example**: Query information about system account 100.
1247
1248  ```ts
1249  import { BusinessError } from '@kit.BasicServicesKit';
1250  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1251  let localId: number = 100;
1252  try {
1253    accountManager.queryOsAccountById(localId, (err: BusinessError, accountInfo: osAccount.OsAccountInfo)=>{
1254      console.log('queryOsAccountById err:' + JSON.stringify(err));
1255      console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo));
1256    });
1257  } catch (e) {
1258    console.log('queryOsAccountById exception: ' + JSON.stringify(e));
1259  }
1260  ```
1261
1262### queryOsAccountById
1263
1264queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt;
1265
1266Queries information about the system account of the given ID. This API uses a promise to return the result.
1267
1268**System API**: This is a system API.
1269
1270**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1271
1272**System capability**: SystemCapability.Account.OsAccount
1273
1274**Parameters**
1275
1276| Name | Type  | Mandatory| Description                |
1277| ------- | ------ | ---- | -------------------- |
1278| localId | number | Yes  | ID of the target system account.|
1279
1280**Return value**
1281
1282| Type                                          | Description                                |
1283| ---------------------------------------------- | ------------------------------------ |
1284| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise used to return the system account information obtained.|
1285
1286**Error codes**
1287
1288| ID| Error Message            |
1289| -------- | ------------------- |
1290| 201 | Permission denied.|
1291| 202 | Not system application.|
1292| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1293| 12300001 | The system service works abnormally. |
1294| 12300002 | Invalid localId. |
1295| 12300003 | Account not found. |
1296
1297**Example**: Query information about system account 100.
1298
1299  ```ts
1300  import { BusinessError } from '@kit.BasicServicesKit';
1301  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1302  let localId: number = 100;
1303  try {
1304    accountManager.queryOsAccountById(localId).then((accountInfo: osAccount.OsAccountInfo) => {
1305      console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo));
1306    }).catch((err: BusinessError) => {
1307      console.log('queryOsAccountById err: ' + JSON.stringify(err));
1308    });
1309  } catch (e) {
1310    console.log('queryOsAccountById exception: ' + JSON.stringify(e));
1311  }
1312  ```
1313
1314### getOsAccountProfilePhoto
1315
1316getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;): void
1317
1318Obtains the profile photo of a system account. This API uses an asynchronous callback to return the result.
1319
1320**System API**: This is a system API.
1321
1322**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1323
1324**System capability**: SystemCapability.Account.OsAccount
1325
1326**Parameters**
1327
1328| Name  | Type                       | Mandatory| Description                                                                        |
1329| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
1330| localId  | number                      | Yes  | ID of the target system account.                                                               |
1331| callback | AsyncCallback&lt;string&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the profile photo information obtained. Otherwise, **err** is an error object.|
1332
1333**Error codes**
1334
1335| ID| Error Message            |
1336| -------- | ------------------- |
1337| 201 | Permission denied.|
1338| 202 | Not system application.|
1339| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1340| 12300001 | The system service works abnormally. |
1341| 12300002 | Invalid localId.    |
1342| 12300003 | Account not found. |
1343
1344**Example**: Obtain the profile photo of system account 100.
1345
1346  ```ts
1347  import { BusinessError } from '@kit.BasicServicesKit';
1348  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1349  let localId: number = 100;
1350  try {
1351    accountManager.getOsAccountProfilePhoto(localId, (err: BusinessError, photo: string)=>{
1352      console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err));
1353      console.log('get photo:' + photo + ' by localId: ' + localId);
1354    });
1355  } catch (e) {
1356    console.log('getOsAccountProfilePhoto exception: ' + JSON.stringify(e));
1357  }
1358  ```
1359
1360### getOsAccountProfilePhoto
1361
1362getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt;
1363
1364Obtains the profile photo of a system account. This API uses a promise to return the result.
1365
1366**System API**: This is a system API.
1367
1368**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1369
1370**System capability**: SystemCapability.Account.OsAccount
1371
1372**Parameters**
1373
1374| Name | Type  | Mandatory| Description        |
1375| ------- | ------ | ---- | ------------ |
1376| localId | number | Yes  | ID of the target system account.|
1377
1378**Return value**
1379
1380| Type                 | Description                                   |
1381| --------------------- | -------------------------------------- |
1382| Promise&lt;string&gt; | Promise used to return the profile photo information obtained.|
1383
1384**Error codes**
1385
1386| ID| Error Message            |
1387| -------- | ------------------- |
1388| 201 | Permission denied.|
1389| 202 | Not system application.|
1390| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1391| 12300001 | The system service works abnormally. |
1392| 12300002 | Invalid localId.    |
1393| 12300003 | Account not found. |
1394
1395**Example**: Obtain the profile photo of system account 100.
1396
1397  ```ts
1398  import { BusinessError } from '@kit.BasicServicesKit';
1399  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1400  let localId: number = 100;
1401  try {
1402    accountManager.getOsAccountProfilePhoto(localId).then((photo: string) => {
1403      console.log('getOsAccountProfilePhoto: ' + photo);
1404    }).catch((err: BusinessError) => {
1405      console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err));
1406    });
1407  } catch (e) {
1408    console.log('getOsAccountProfilePhoto exception: ' + JSON.stringify(e));
1409  }
1410  ```
1411
1412### setOsAccountProfilePhoto
1413
1414setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback&lt;void&gt;): void
1415
1416Sets a profile photo for a system account. This API uses an asynchronous callback to return the result.
1417
1418**System API**: This is a system API.
1419
1420**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1421
1422**System capability**: SystemCapability.Account.OsAccount
1423
1424**Parameters**
1425
1426| Name  | Type                     | Mandatory| Description        |
1427| -------- | ------------------------- | ---- | ------------ |
1428| localId  | number                    | Yes  | ID of the target system account.|
1429| photo    | string                    | Yes  | Profile photo information.  |
1430| callback | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object. |
1431
1432**Error codes**
1433
1434| ID| Error Message            |
1435| -------- | ------------------- |
1436| 201 | Permission denied.|
1437| 202 | Not system application.|
1438| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1439| 12300001 | The system service works abnormally. |
1440| 12300002 | Invalid localId or photo.    |
1441| 12300003 | Account not found. |
1442| 12300008 | Restricted Account. |
1443
1444**Example**: Set a profile photo for system account 100.
1445
1446  ```ts
1447  import { BusinessError } from '@kit.BasicServicesKit';
1448  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1449  let localId: number = 100;
1450  let photo: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
1451  'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
1452  'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
1453  '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
1454  try {
1455    accountManager.setOsAccountProfilePhoto(localId, photo, (err: BusinessError)=>{
1456      console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err));
1457    });
1458  } catch (e) {
1459    console.log('setOsAccountProfilePhoto exception: ' + JSON.stringify(e));
1460  }
1461  ```
1462
1463### setOsAccountProfilePhoto
1464
1465setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;
1466
1467Sets a profile photo for a system account. This API uses a promise to return the result.
1468
1469**System API**: This is a system API.
1470
1471**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1472
1473**System capability**: SystemCapability.Account.OsAccount
1474
1475**Parameters**
1476
1477| Name | Type  | Mandatory| Description        |
1478| ------- | ------ | ---- | ------------ |
1479| localId | number | Yes  | ID of the target system account.|
1480| photo   | string | Yes  | Profile photo information.  |
1481
1482**Return value**
1483
1484| Type               | Description                                |
1485| ------------------- | ------------------------------------ |
1486| Promise&lt;void&gt; | Promise that returns no value.|
1487
1488**Error codes**
1489
1490| ID| Error Message            |
1491| -------- | ------------------- |
1492| 201 | Permission denied.|
1493| 202 | Not system application.|
1494| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1495| 12300001 | The system service works abnormally. |
1496| 12300002 | Invalid localId or photo.    |
1497| 12300003 | Account not found. |
1498| 12300008 | Restricted Account. |
1499
1500**Example**: Set a profile photo for system account 100.
1501
1502  ```ts
1503  import { BusinessError } from '@kit.BasicServicesKit';
1504  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1505  let localId: number = 100;
1506  let photo: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
1507  'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
1508  'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
1509  '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
1510  try {
1511    accountManager.setOsAccountProfilePhoto(localId, photo).then(() => {
1512      console.log('setOsAccountProfilePhoto success');
1513    }).catch((err: BusinessError) => {
1514      console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err));
1515    });
1516  } catch (e) {
1517    console.log('setOsAccountProfilePhoto exception: ' + JSON.stringify(e));
1518  }
1519  ```
1520
1521### on
1522
1523on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&gt;): void
1524
1525Subscribes to the system account activation states, including the states of the account being activated and the account with activation completed. This API uses an asynchronous callback to return the result.
1526
1527**System API**: This is a system API.
1528
1529**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1530
1531**System capability**: SystemCapability.Account.OsAccount
1532
1533**Parameters**
1534
1535| Name  | Type                      | Mandatory| Description                                                        |
1536| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1537| type     | 'activate' \| 'activating' | Yes  | Type of the event to subscribe to. The value **activate** indicates a system account is activated, and **activating** indicates a system account is being activated.|
1538| name     | string                     | Yes  | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes.          |
1539| callback | Callback&lt;number&gt;     | Yes  | Callback used to return the ID of the system account being activated or activated.   |
1540
1541**Error codes**
1542
1543| ID| Error Message      |
1544| -------- | ------------- |
1545| 201 | Permission denied.|
1546| 202 | Not system application.|
1547| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1548| 12300001 | The system service works abnormally. |
1549| 12300002 | Invalid type or name. |
1550
1551**Example**
1552
1553  ```ts
1554  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1555  function onCallback(receiveLocalId: number){
1556    console.log('receive localId:' + receiveLocalId);
1557  }
1558  try {
1559    accountManager.on('activating', 'osAccountOnOffNameA', onCallback);
1560  } catch (e) {
1561    console.log('receive localId exception: ' + JSON.stringify(e));
1562  }
1563  ```
1564
1565### off
1566
1567off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number&gt;): void
1568
1569Unsubscribes from the system account activation states, including the states of the account being activated and the account with activation completed. This API uses an asynchronous callback to return the result.
1570
1571**System API**: This is a system API.
1572
1573**Required permissions**: ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1574
1575**System capability**: SystemCapability.Account.OsAccount
1576
1577**Parameters**
1578
1579| Name  | Type                      | Mandatory| Description                                                        |
1580| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1581| type     | 'activate' \| 'activating' | Yes  | Type of the event to unsubscribe from. The value **activate** indicates that a system account is activated, and **activating** indicates that a system account is being activated.|
1582| name     | string                     | Yes  | Subscription name, which can be customized. The value cannot be empty or exceed 1024 bytes, and must be the same as the value passed by **on()**.|
1583| callback | Callback&lt;number&gt;     | No  | Callback to unregister. By default, this parameter is left empty, which unregisters all callbacks for the system account activation states.                     |
1584
1585**Error codes**
1586
1587| ID| Error Message      |
1588| -------- | ------------- |
1589| 201 | Permission denied.|
1590| 202 | Not system application.|
1591| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1592| 12300001 | The system service works abnormally. |
1593| 12300002 | Invalid type or name. |
1594
1595**Example**
1596
1597  ```ts
1598  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1599  function offCallback(){
1600    console.log('off enter')
1601  }
1602  try {
1603    accountManager.off('activating', 'osAccountOnOffNameA', offCallback);
1604  } catch (e) {
1605    console.log('off exception: ' + JSON.stringify(e));
1606  }
1607  ```
1608
1609### on<sup>12+</sup>
1610
1611on(type: 'switching', callback: Callback&lt;OsAccountSwitchEventData&gt;): void
1612
1613Subscribes to the switchover between a foreground system account and a background system account in progress. This API uses an asynchronous callback to return the result.
1614
1615**System API**: This is a system API.
1616
1617**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1618
1619**System capability**: SystemCapability.Account.OsAccount
1620
1621**Parameters**
1622
1623| Name  | Type                      | Mandatory| Description                                                        |
1624| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1625| type     | 'switching'                 | Yes  | Event type. The value **switching** indicates that the switchover between a foreground system account and a background account is being performed.|
1626| callback | Callback&lt;[OsAccountSwitchEventData](#osaccountswitcheventdata12)&gt;     | Yes  | Callback used to return the system account IDs before and after the switchover.   |
1627
1628**Error codes**
1629
1630| ID| Error Message      |
1631| -------- | ------------- |
1632| 201 | Permission denied.|
1633| 202 | Not system application.|
1634| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1635| 12300001 | The system service works abnormally. |
1636| 12300002 | Invalid type. |
1637
1638**Example**
1639
1640  ```ts
1641  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1642  function onSwitchingCallback(eventData: osAccount.OsAccountSwitchEventData){
1643    console.log('receive eventData:' + JSON.stringify(eventData));
1644  }
1645  try {
1646    accountManager.on('switching', onSwitchingCallback);
1647  } catch (e) {
1648    console.log('receive eventData exception: ' + JSON.stringify(e));
1649  }
1650  ```
1651
1652### off<sup>12+</sup>
1653
1654off(type: 'switching', callback?: Callback&lt;OsAccountSwitchEventData&gt;): void
1655
1656Unsubscribes from the switchover between a foreground system account and a background system account in progress. This API uses an asynchronous callback to return the result.
1657
1658**System API**: This is a system API.
1659
1660**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1661
1662**System capability**: SystemCapability.Account.OsAccount
1663
1664**Parameters**
1665
1666| Name  | Type                      | Mandatory| Description                                                        |
1667| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1668| type     | 'switching'                 | Yes  | Event type. The value **switching** indicates that the switchover between a foreground system account and a background account is being performed.|
1669| callback | Callback&lt;[OsAccountSwitchEventData](#osaccountswitcheventdata12)&gt;     | No  | Callback to unregister. By default, this parameter is left empty, which unregisters all callbacks for the **switching** event.                     |
1670
1671**Error codes**
1672
1673| ID| Error Message      |
1674| -------- | ------------- |
1675| 201 | Permission denied.|
1676| 202 | Not system application.|
1677| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1678| 12300001 | The system service works abnormally. |
1679| 12300002 | Invalid type. |
1680
1681**Example**
1682
1683  ```ts
1684  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1685  try {
1686    accountManager.off('switching');
1687  } catch (e) {
1688    console.log('off exception: ' + JSON.stringify(e));
1689  }
1690  ```
1691
1692### on<sup>12+</sup>
1693
1694on(type: 'switched', callback: Callback&lt;OsAccountSwitchEventData&gt;): void
1695
1696Subscribes to the end of a switchover between a foreground system account and a background system account. This API uses an asynchronous callback to return the result.
1697
1698**System API**: This is a system API.
1699
1700**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1701
1702**System capability**: SystemCapability.Account.OsAccount
1703
1704**Parameters**
1705
1706| Name  | Type                      | Mandatory| Description                                                        |
1707| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1708| type     | 'switched'                 | Yes  | Event type. The value **switched** indicates that the switchover between a foreground system account and a background system account is complete.|
1709| callback | Callback&lt;[OsAccountSwitchEventData](#osaccountswitcheventdata12)&gt;     | Yes  | Callback used to return the system account IDs before and after the switchover.   |
1710
1711**Error codes**
1712
1713| ID| Error Message      |
1714| -------- | ------------- |
1715| 201 | Permission denied.|
1716| 202 | Not system application.|
1717| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1718| 12300001 | The system service works abnormally. |
1719| 12300002 | Invalid type. |
1720
1721**Example**
1722
1723  ```ts
1724  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1725  function onSwitchedCallback(eventData: osAccount.OsAccountSwitchEventData){
1726    console.log('receive eventData:' + JSON.stringify(eventData));
1727  }
1728  try {
1729    accountManager.on('switched', onSwitchedCallback);
1730  } catch (e) {
1731    console.log('receive eventData exception: ' + JSON.stringify(e));
1732  }
1733  ```
1734
1735### off<sup>12+</sup>
1736
1737off(type: 'switched', callback?: Callback&lt;OsAccountSwitchEventData&gt;): void
1738
1739Unsubscribes from the end of a switchover between a foreground system account and a background system account. This API uses an asynchronous callback to return the result.
1740
1741**System API**: This is a system API.
1742
1743**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1744
1745**System capability**: SystemCapability.Account.OsAccount
1746
1747**Parameters**
1748
1749| Name  | Type                      | Mandatory| Description                                                        |
1750| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1751| type     | 'switched'                 | Yes  | Event type. The value **switched** indicates that the switchover between a foreground system account and a background system account is complete.|
1752| callback | Callback&lt;[OsAccountSwitchEventData](#osaccountswitcheventdata12)&gt;     | No  | Callback to unregister. By default, this parameter is left empty, which unregisters all callbacks for the **switched** event.                     |
1753
1754**Error codes**
1755
1756| ID| Error Message      |
1757| -------- | ------------- |
1758| 201 | Permission denied.|
1759| 202 | Not system application.|
1760| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1761| 12300001 | The system service works abnormally. |
1762| 12300002 | Invalid type. |
1763
1764**Example**
1765
1766  ```ts
1767  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1768  try {
1769    accountManager.off('switched');
1770  } catch (e) {
1771    console.log('off exception: ' + JSON.stringify(e));
1772  }
1773  ```
1774
1775### getBundleIdForUid<sup>9+</sup>
1776
1777getBundleIdForUid(uid: number, callback: AsyncCallback&lt;number&gt;): void
1778
1779Obtains the bundle ID based on the UID. This API uses an asynchronous callback to return the result.
1780
1781**System API**: This is a system API.
1782
1783**System capability**: SystemCapability.Account.OsAccount
1784
1785**Parameters**
1786
1787| Name  | Type                      | Mandatory| Description                                                                       |
1788| -------- | --------------------------- | ---- | ------------------------------------------------------------------------ |
1789| uid      | number                      | Yes  | Process UID.                                                                |
1790| callback | AsyncCallback&lt;number&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the bundle ID obtained. Otherwise, **data** is an error object.|
1791
1792**Error codes**
1793
1794| ID| Error Message      |
1795| -------- | ------------- |
1796| 202 | Not system application.|
1797| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1798| 12300001 | The system service works abnormally. |
1799| 12300002 | Invalid uid. |
1800
1801**Example**
1802
1803  ```ts
1804  import { BusinessError } from '@kit.BasicServicesKit';
1805  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1806  let testUid: number = 1000000;
1807  try {
1808    accountManager.getBundleIdForUid(testUid, (err: BusinessError, bundleId: number) => {
1809      console.info('getBundleIdForUid errInfo:' + JSON.stringify(err));
1810      console.info('getBundleIdForUid bundleId:' + JSON.stringify(bundleId));
1811    });
1812  } catch (e) {
1813    console.info('getBundleIdForUid exception: ' + JSON.stringify(e));
1814  }
1815  ```
1816
1817### getBundleIdForUid<sup>9+</sup>
1818
1819getBundleIdForUid(uid: number): Promise&lt;number&gt;
1820
1821Obtains the bundle ID based on the UID. This API uses a promise to return the result.
1822
1823**System API**: This is a system API.
1824
1825**System capability**: SystemCapability.Account.OsAccount
1826
1827**Parameters**
1828
1829| Name | Type  | Mandatory| Description        |
1830| ------- | ------ | ---- | ------------ |
1831| uid     | number | Yes  |  Process UID.|
1832
1833**Return value**
1834
1835| Type                 | Description                                 |
1836| --------------------- | ------------------------------------ |
1837| Promise&lt;number&gt; | Promise used to return the bundle ID obtained.|
1838
1839**Error codes**
1840
1841| ID| Error Message      |
1842| -------- | ------------- |
1843| 202 | Not system application.|
1844| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1845| 12300001 | The system service works abnormally. |
1846| 12300002 | Invalid uid. |
1847
1848**Example**
1849
1850  ```ts
1851  import { BusinessError } from '@kit.BasicServicesKit';
1852  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1853  let testUid: number = 1000000;
1854  try {
1855    accountManager.getBundleIdForUid(testUid).then((result: number) => {
1856      console.info('getBundleIdForUid bundleId:' + JSON.stringify(result));
1857    }).catch((err: BusinessError) => {
1858      console.info('getBundleIdForUid errInfo:' + JSON.stringify(err));
1859    });
1860  } catch (e) {
1861    console.info('getBundleIdForUid exception: ' + JSON.stringify(e));
1862  }
1863  ```
1864
1865### getBundleIdForUidSync<sup>10+</sup>
1866
1867getBundleIdForUidSync(uid: number): number
1868
1869Obtains the bundle ID based on the specified UID. The API returns the result synchronously.
1870
1871**System API**: This is a system API.
1872
1873**System capability**: SystemCapability.Account.OsAccount
1874
1875**Parameters**
1876
1877| Name | Type  | Mandatory| Description        |
1878| ------- | ------ | ---- | ------------ |
1879| uid     | number | Yes  |  Process UID.|
1880
1881**Return value**
1882
1883| Type  | Description                    |
1884| ------ | ------------------------ |
1885| number | Bundle ID obtained.|
1886
1887**Error codes**
1888
1889| ID| Error Message      |
1890| -------- | ------------- |
1891| 202 | Not system application.|
1892| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1893| 12300002 | Invalid uid. |
1894
1895**Example**
1896
1897  ```ts
1898  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1899  let testUid: number = 1000000;
1900  try {
1901    let bundleId : number = accountManager.getBundleIdForUidSync(testUid);
1902    console.info('getBundleIdForUidSync bundleId:' + bundleId);
1903  } catch (e) {
1904    console.info('getBundleIdForUidSync exception: ' + JSON.stringify(e));
1905  }
1906  ```
1907
1908### isMainOsAccount<sup>9+</sup>
1909
1910isMainOsAccount(callback: AsyncCallback&lt;boolean&gt;): void
1911
1912Checks whether the current process belongs to the main system account. This API uses an asynchronous callback to return the result.
1913
1914**System API**: This is a system API.
1915
1916**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1917
1918**System capability**: SystemCapability.Account.OsAccount
1919
1920**Parameters**
1921
1922| Name  | Type                         | Mandatory| Description                                                              |
1923| -------- | ---------------------------- | ---- | ----------------------------------------------------------------- |
1924| callback | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result. If **true** is returned, the current process belongs to the main system account. If **false** is returned, the current process does not belong to the main system account.|
1925
1926**Error codes**
1927
1928| ID| Error Message      |
1929| -------- | ------------- |
1930| 201 | Permission denied.|
1931| 202 | Not system application.|
1932| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
1933| 12300001 | The system service works abnormally. |
1934
1935**Example**
1936
1937  ```ts
1938  import { BusinessError } from '@kit.BasicServicesKit';
1939  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1940  try {
1941    accountManager.isMainOsAccount((err: BusinessError,result: boolean)=>{
1942      console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
1943      console.info('isMainOsAccount result:' + JSON.stringify(result));
1944    });
1945  } catch (e) {
1946    console.info('isMainOsAccount exception: ' + JSON.stringify(e));
1947  }
1948  ```
1949
1950### isMainOsAccount<sup>9+</sup>
1951
1952isMainOsAccount(): Promise&lt;boolean&gt;;
1953
1954Checks whether the current process belongs to the main system account. This API uses a promise to return the result.
1955
1956**System API**: This is a system API.
1957
1958**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
1959
1960**System capability**: SystemCapability.Account.OsAccount
1961
1962**Return value**
1963
1964| Type                  | Description                                                                 |
1965| ---------------------- | --------------------------------------------------------------------- |
1966| Promise&lt;boolean&gt; | Promise used to return the result. If **true** is returned, the current process belongs to the main system account. If **false** is returned, the current process does not belong to the main system account.|
1967
1968**Error codes**
1969
1970| ID| Error Message      |
1971| -------- | ------------- |
1972| 201 | Permission denied.|
1973| 202 | Not system application.|
1974| 12300001 | The system service works abnormally. |
1975
1976**Example**
1977
1978  ```ts
1979  import { BusinessError } from '@kit.BasicServicesKit';
1980  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
1981  try {
1982    accountManager.isMainOsAccount().then((result: boolean) => {
1983      console.info('isMainOsAccount result:' + JSON.stringify(result));
1984    }).catch((err: BusinessError) => {
1985      console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
1986    });
1987  } catch (e) {
1988    console.info('isMainOsAccount exception: ' + JSON.stringify(e));
1989  }
1990  ```
1991
1992### getOsAccountConstraintSourceTypes<sup>9+</sup>
1993
1994getOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback&lt;Array&lt;ConstraintSourceTypeInfo&gt;&gt;): void
1995
1996Obtains the constraint source information of a system account. This API uses an asynchronous callback to return the result.
1997
1998**System API**: This is a system API.
1999
2000**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
2001
2002**System capability**: SystemCapability.Account.OsAccount
2003
2004**Parameters**
2005
2006| Name  | Type                      | Mandatory| Description                                                        |
2007| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
2008| localId     | number | Yes  |  ID of the target system account.|
2009| constraint     | string | Yes  |  [Constraint](js-apis-osAccount.md#constraints) whose source information is to be obtained.|
2010| callback | AsyncCallback&lt;Array&lt;[ConstraintSourceTypeInfo](#constraintsourcetypeinfo9)&gt;&gt;     | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the [constraint](js-apis-osAccount.md#constraints) source information obtained. Otherwise, **err** is an error object.                     |
2011
2012**Error codes**
2013
2014| ID| Error Message      |
2015| -------- | ------------- |
2016| 201 | Permission denied.|
2017| 202 | Not system application.|
2018| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2019| 12300001 | The system service works abnormally. |
2020| 12300002 | Invalid name or constraint. |
2021| 12300003 | Account not found. |
2022
2023**Example**
2024
2025  ```ts
2026  import { BusinessError } from '@kit.BasicServicesKit';
2027  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2028  try {
2029    accountManager.getOsAccountConstraintSourceTypes(100, 'constraint.wifi',
2030      (err: BusinessError,sourceTypeInfos: osAccount.ConstraintSourceTypeInfo[])=>{
2031      console.info('getOsAccountConstraintSourceTypes errInfo:' + JSON.stringify(err));
2032      console.info('getOsAccountConstraintSourceTypes sourceTypeInfos:' + JSON.stringify(sourceTypeInfos));
2033    });
2034  } catch (e) {
2035    console.info('getOsAccountConstraintSourceTypes exception: ' + JSON.stringify(e));
2036  }
2037  ```
2038
2039### getOsAccountConstraintSourceTypes<sup>9+</sup>
2040
2041getOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise&lt;Array&lt;ConstraintSourceTypeInfo&gt;&gt;;
2042
2043Obtains the constraint source information of a system account. This API uses a promise to return the result.
2044
2045**System API**: This is a system API.
2046
2047**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
2048
2049**System capability**: SystemCapability.Account.OsAccount
2050
2051**Parameters**
2052
2053| Name | Type  | Mandatory| Description        |
2054| ------- | ------ | ---- | ------------ |
2055| localId     | number | Yes  |  ID of the target system account.|
2056| constraint     | string | Yes  |  [Constraint](js-apis-osAccount.md#constraints) whose source information is to be obtained.|
2057
2058**Return value**
2059
2060| Type                 | Description                                                        |
2061| --------------------- | ------------------------------------------------------------ |
2062| Promise&lt;Array&lt;[ConstraintSourceTypeInfo](#constraintsourcetypeinfo9)&gt;&gt; | Promise used to return the source information of the specified [constraint](js-apis-osAccount.md#constraints).|
2063
2064**Error codes**
2065
2066| ID| Error Message      |
2067| -------- | ------------- |
2068| 201 | Permission denied.|
2069| 202 | Not system application.|
2070| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2071| 12300001 | The system service works abnormally. |
2072| 12300002 | Invalid name or constraint. |
2073| 12300003 | Account not found. |
2074
2075**Example**
2076
2077  ```ts
2078  import { BusinessError } from '@kit.BasicServicesKit';
2079  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2080  try {
2081    accountManager.getOsAccountConstraintSourceTypes(100, 'constraint.wifi').then(
2082      (result: osAccount.ConstraintSourceTypeInfo[]) => {
2083      console.info('getOsAccountConstraintSourceTypes sourceTypeInfos:' + JSON.stringify(result));
2084    }).catch((err: BusinessError) => {
2085      console.info('getOsAccountConstraintSourceTypes errInfo:' + JSON.stringify(err));
2086    });
2087  } catch (e) {
2088    console.info('getOsAccountConstraintSourceTypes exception: ' + JSON.stringify(e));
2089  }
2090  ```
2091
2092### getOsAccountType<sup>12+</sup>
2093
2094getOsAccountType(localId: number): Promise&lt;OsAccountType&gt;;
2095
2096Obtains the type of a system account. This API uses a promise to return the result.
2097
2098**System API**: This is a system API.
2099
2100**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
2101
2102**System capability**: SystemCapability.Account.OsAccount
2103
2104**Parameters**
2105
2106| Name | Type  | Mandatory| Description        |
2107| ------- | ------ | ---- | ------------ |
2108| localId     | number | Yes  |  ID of the target system account.|
2109
2110**Return value**
2111
2112| Type                 | Description                                                        |
2113| --------------------- | ------------------------------------------------------------ |
2114| Promise&lt;[OsAccountType](js-apis-osAccount.md#osaccounttype)&gt; | Promise used to return the type of the system account obtained.|
2115
2116**Error codes**
2117
2118| ID| Error Message      |
2119| -------- | ------------- |
2120| 201 | Permission denied.|
2121| 202 | Not system application.|
2122| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2123| 12300001 | The system service works abnormally. |
2124| 12300003 | Account not found. |
2125
2126**Example**
2127
2128  ```ts
2129  import { BusinessError } from '@kit.BasicServicesKit';
2130  let accountManager: osAccount.AccountManager = osAccount.getAccountManager();
2131  try {
2132    let localId: number = 100;
2133    accountManager.getOsAccountType(localId).then((type: osAccount.OsAccountType) => {
2134      console.info('getOsAccountType Type:' + type);
2135    }).catch((err: BusinessError) => {
2136      console.info('getOsAccountType errInfo:' + JSON.stringify(err));
2137    });
2138  } catch (e) {
2139    console.info('getOsAccountType exception: ' + JSON.stringify(e));
2140  }
2141  ```
2142
2143## UserAuth<sup>8+</sup>
2144
2145Provides APIs for user authentication.
2146
2147**System API**: This is a system API.
2148
2149### constructor<sup>8+</sup>
2150
2151constructor()
2152
2153A constructor used to create an instance for user authentication.
2154
2155**System API**: This is a system API.
2156
2157**System capability**: SystemCapability.Account.OsAccount
2158
2159**Error codes**
2160
2161| ID| Error Message      |
2162| -------- | ------------- |
2163| 202 | Not system application.|
2164
2165**Example**
2166  ```ts
2167  let userAuth = new osAccount.UserAuth();
2168  ```
2169
2170### getVersion<sup>8+</sup>
2171
2172getVersion(): number;
2173
2174Obtains version information.
2175
2176**System API**: This is a system API.
2177
2178**System capability**: SystemCapability.Account.OsAccount
2179
2180**Return value**
2181
2182| Type  | Description        |
2183| :----- | :----------- |
2184| number | Version information obtained.|
2185
2186**Error codes**
2187
2188| ID| Error Message      |
2189| -------- | ------------- |
2190| 202 | Not system application.|
2191
2192**Example**
2193  ```ts
2194  let userAuth = new osAccount.UserAuth();
2195  let version: number = userAuth.getVersion();
2196  console.log('getVersion version = ' + version);
2197  ```
2198
2199### getAvailableStatus<sup>8+</sup>
2200
2201getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number;
2202
2203Obtains the available status of the authentication capability corresponding to the specified authentication type and trust level.
2204
2205**System API**: This is a system API.
2206
2207**System capability**: SystemCapability.Account.OsAccount
2208
2209**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2210
2211**Parameters**
2212
2213| Name          | Type                              | Mandatory| Description                      |
2214| --------------- | -----------------------------------| ---- | ------------------------- |
2215| authType        | [AuthType](#authtype8)             | Yes  | Authentication credential type.    |
2216| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8) | Yes  | Trust level of the authentication.|
2217
2218**Return value**
2219
2220| Type  | Description                          |
2221| ------ | ----------------------------- |
2222| number | Available status of the authentication capability.|
2223
2224**Error codes**
2225
2226| ID| Error Message                    |
2227| -------- | --------------------------- |
2228| 201 | Permission denied.|
2229| 202 | Not system application.|
2230| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2231| 12300001 | The system service works abnormally. |
2232| 12300002 | Invalid authType or authTrustLevel. |
2233
2234**Example**
2235  ```ts
2236  let userAuth = new osAccount.UserAuth();
2237  let authType: osAccount.AuthType = osAccount.AuthType.PIN;
2238  let authTrustLevel: osAccount.AuthTrustLevel = osAccount.AuthTrustLevel.ATL1;
2239  try {
2240    let status: number = userAuth.getAvailableStatus(authType, authTrustLevel);
2241    console.log('getAvailableStatus status = ' + status);
2242  } catch (e) {
2243    console.log('getAvailableStatus exception = ' + JSON.stringify(e));
2244  }
2245  ```
2246
2247### getProperty<sup>8+</sup>
2248
2249getProperty(request: GetPropertyRequest, callback: AsyncCallback&lt;ExecutorProperty&gt;): void
2250
2251Obtains the executor property based on the request. This API uses an asynchronous callback to return the result.
2252
2253**System API**: This is a system API.
2254
2255**System capability**: SystemCapability.Account.OsAccount
2256
2257**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2258
2259**Parameters**
2260
2261| Name   | Type                                                                   | Mandatory| Description                               |
2262| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------ |
2263| request  | [GetPropertyRequest](#getpropertyrequest8)                  | Yes  | Request information, including the authentication credential type and property list.|
2264| callback | AsyncCallback&lt;[ExecutorProperty](#executorproperty8)&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the executor property information obtained. Otherwise, **err** is an error object.|
2265
2266**Error codes**
2267
2268| ID| Error Message                    |
2269| -------- | --------------------------- |
2270| 201 | Permission denied.|
2271| 202 | Not system application.|
2272| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2273| 12300001 | The system service works abnormally. |
2274| 12300002 | Invalid request. |
2275| 12300003 | Account not found. |
2276
2277**Example**
2278  ```ts
2279  import { BusinessError } from '@kit.BasicServicesKit';
2280  let userAuth = new osAccount.UserAuth();
2281  let keys: Array<osAccount.GetPropertyType>  = [
2282    osAccount.GetPropertyType.AUTH_SUB_TYPE,
2283    osAccount.GetPropertyType.REMAIN_TIMES,
2284    osAccount.GetPropertyType.FREEZING_TIME
2285  ];
2286  let request: osAccount.GetPropertyRequest = {
2287    authType: osAccount.AuthType.PIN,
2288    keys: keys
2289  };
2290  try {
2291    userAuth.getProperty(request, (err: BusinessError, result: osAccount.ExecutorProperty) => {
2292      console.log('getProperty err = ' + JSON.stringify(err));
2293      console.log('getProperty result = ' + JSON.stringify(result));
2294    });
2295  } catch (e) {
2296    console.log('getProperty exception = ' + JSON.stringify(e));
2297  }
2298  ```
2299
2300### getProperty<sup>8+</sup>
2301
2302getProperty(request: GetPropertyRequest): Promise&lt;ExecutorProperty&gt;;
2303
2304Obtains the executor property based on the request. This API uses a promise to return the result.
2305
2306**System API**: This is a system API.
2307
2308**System capability**: SystemCapability.Account.OsAccount
2309
2310**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2311
2312**Parameters**
2313
2314| Name   | Type                                                  | Mandatory| Description                               |
2315| -------- | ------------------------------------------------------ | ---- | ---------------------------------- |
2316| request  | [GetPropertyRequest](#getpropertyrequest8) | Yes  | Request information, including the authentication credential type and property list.|
2317
2318**Return value**
2319
2320| Type                                                             | Description                                                |
2321| :---------------------------------------------------------------- | :-------------------------------------------------- |
2322| Promise&lt;[ExecutorProperty](#executorproperty8)&gt; | Promise used to return the executor property information obtained.|
2323
2324**Error codes**
2325
2326| ID| Error Message                    |
2327| -------- | --------------------------- |
2328| 201 | Permission denied.|
2329| 202 | Not system application.|
2330| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2331| 12300001 | The system service works abnormally. |
2332| 12300002 | Invalid request. |
2333| 12300003 | Account not found. |
2334
2335**Example**
2336  ```ts
2337  import { BusinessError } from '@kit.BasicServicesKit';
2338  let userAuth = new osAccount.UserAuth();
2339  let keys: Array<osAccount.GetPropertyType> = [
2340    osAccount.GetPropertyType.AUTH_SUB_TYPE,
2341    osAccount.GetPropertyType.REMAIN_TIMES,
2342    osAccount.GetPropertyType.FREEZING_TIME
2343  ];
2344  let request: osAccount.GetPropertyRequest = {
2345    authType: osAccount.AuthType.PIN,
2346    keys: keys
2347  };
2348  try {
2349    userAuth.getProperty(request).then((result: osAccount.ExecutorProperty) => {
2350      console.log('getProperty result = ' + JSON.stringify(result));
2351    }).catch((err: BusinessError) => {
2352      console.log('getProperty error = ' + JSON.stringify(err));
2353    });
2354  } catch (e) {
2355    console.log('getProperty exception = ' + JSON.stringify(e));
2356  }
2357  ```
2358
2359### setProperty<sup>8+</sup>
2360
2361setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;void&gt;): void
2362
2363Sets the property for the initialization algorithm. This API uses an asynchronous callback to return the result.
2364
2365**System API**: This is a system API.
2366
2367**System capability**: SystemCapability.Account.OsAccount
2368
2369**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2370
2371**Parameters**
2372
2373| Name   | Type                                                 | Mandatory| Description                                                                   |
2374| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- |
2375| request  | [SetPropertyRequest](#setpropertyrequest8)| Yes  | Request information, including the authentication credential type and the key value to set.                                  |
2376| callback | AsyncCallback&lt;void&gt;                           | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, **err** is an error object.|
2377
2378**Error codes**
2379
2380| ID| Error Message                    |
2381| -------- | --------------------------- |
2382| 201 | Permission denied.|
2383| 202 | Not system application.|
2384| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2385| 12300001 | The system service works abnormally. |
2386| 12300002 | Invalid request. |
2387
2388**Example**
2389  ```ts
2390  import { BusinessError } from '@kit.BasicServicesKit';
2391  let userAuth = new osAccount.UserAuth();
2392  let request: osAccount.SetPropertyRequest = {
2393    authType: osAccount.AuthType.PIN,
2394    key: osAccount.SetPropertyType.INIT_ALGORITHM,
2395    setInfo: new Uint8Array([0])
2396  };
2397  try {
2398    userAuth.setProperty(request, (err: BusinessError) => {
2399      if (err) {
2400        console.log('setProperty failed, error = ' + JSON.stringify(err));
2401      } else {
2402        console.log('setProperty successfully');
2403      }
2404    });
2405  } catch (e) {
2406    console.log('setProperty exception = ' + JSON.stringify(e));
2407  }
2408  ```
2409
2410### setProperty<sup>8+</sup>
2411
2412setProperty(request: SetPropertyRequest): Promise&lt;void&gt;;
2413
2414Sets the property for the initialization algorithm. This API uses a promise to return the result.
2415
2416**System API**: This is a system API.
2417
2418**System capability**: SystemCapability.Account.OsAccount
2419
2420**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2421
2422**Parameters**
2423
2424| Name   | Type                                      | Mandatory| Description                                     |
2425| -------- | ------------------------------------------ | ---- | ---------------------------------------- |
2426| request  | [SetPropertyRequest](#setpropertyrequest8) | Yes  | Request information, including the authentication credential type and the key value to set.|
2427
2428**Return value**
2429
2430| Type                 | Description                                                          |
2431| :-------------------- | :------------------------------------------------------------ |
2432| Promise&lt;void&gt; | Promise that returns no value.|
2433
2434**Error codes**
2435
2436| ID| Error Message                    |
2437| -------- | --------------------------- |
2438| 201 | Permission denied.|
2439| 202 | Not system application.|
2440| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2441| 12300001 | The system service works abnormally. |
2442| 12300002 | Invalid request. |
2443
2444**Example**
2445  ```ts
2446  import { BusinessError } from '@kit.BasicServicesKit';
2447  let userAuth = new osAccount.UserAuth();
2448  let request: osAccount.SetPropertyRequest = {
2449    authType: osAccount.AuthType.PIN,
2450    key: osAccount.SetPropertyType.INIT_ALGORITHM,
2451    setInfo: new Uint8Array([0])
2452  };
2453  try {
2454    userAuth.setProperty(request).then(() => {
2455      console.log('setProperty successfully');
2456    }).catch((err: BusinessError) => {
2457      console.log('setProperty failed, error = ' + JSON.stringify(err));
2458    });
2459  } catch (e) {
2460    console.log('setProperty exception = ' + JSON.stringify(e));
2461  }
2462  ```
2463
2464### prepareRemoteAuth<sup>12+</sup>
2465
2466prepareRemoteAuth(remoteNetworkId: string): Promise&lt;void&gt;;
2467
2468Prepares for remote authentication. This API uses a promise to return the result.
2469
2470**System API**: This is a system API.
2471
2472**System capability**: SystemCapability.Account.OsAccount
2473
2474**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2475
2476**Parameters**
2477
2478| Name           | Type  | Mandatory| Description            |
2479| --------         | ------ | ---- | --------------- |
2480| remoteNetworkId  | string | Yes  | Remote network ID. |
2481
2482**Return value**
2483
2484| Type                 | Description                                                          |
2485| :-------------------- | :------------------------------------------------------------ |
2486| Promise&lt;void&gt; | Promise that returns no value.|
2487
2488**Error codes**
2489
2490| ID| Error Message                    |
2491| -------- | --------------------------- |
2492| 201 | Permission denied.|
2493| 202 | Not system application.|
2494| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2495| 12300001 | System service exception. |
2496| 12300002 | Invalid remoteNetworkId. |
2497
2498**Example**
2499  ```ts
2500  import { distributedDeviceManager } from '@kit.DistributedServiceKit';
2501  import { BusinessError } from '@kit.BasicServicesKit';
2502
2503  let userAuth = new osAccount.UserAuth();
2504  let distributedDeviceMgr = distributedDeviceManager.createDeviceManager("com.example.bundleName");
2505  distributedDeviceMgr.getAvailableDeviceList().then((data: Array<distributedDeviceManager.DeviceBasicInfo>) => {
2506      try {
2507        if (data.length > 0 && data[0].networkId != null) {
2508          userAuth.prepareRemoteAuth(data[0].networkId).then(() => {
2509            console.log('prepareRemoteAuth successfully');
2510          }).catch((err: BusinessError) => {
2511            console.log('prepareRemoteAuth failed, error = ' + JSON.stringify(err));
2512          });
2513        }
2514      } catch (e) {
2515        console.log('prepareRemoteAuth exception = ' + JSON.stringify(e));
2516      }
2517    }
2518  )
2519  ```
2520
2521### auth<sup>8+</sup>
2522
2523auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
2524
2525Performs authentication of the current user. This API uses an asynchronous callback to return the result.
2526
2527**System API**: This is a system API.
2528
2529**System capability**: SystemCapability.Account.OsAccount
2530
2531**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2532
2533**Parameters**
2534
2535| Name          | Type                                    | Mandatory| Description                               |
2536| --------------- | ---------------------------------------- | --- | ------------------------------------ |
2537| challenge       | Uint8Array                               | Yes | Challenge value, which is a random number used to improve security.|
2538| authType        | [AuthType](#authtype8)                   | Yes | Authentication credential type.                       |
2539| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8)       | Yes | Trust level of the authentication result.              |
2540| callback        | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback used to return the authentication result. |
2541
2542**Return value**
2543
2544| Type       | Description              |
2545| ---------- | ------------------ |
2546| Uint8Array | ID of the context for canceling the authentication.|
2547
2548**Error codes**
2549
2550| ID| Error Message         |
2551| -------- | --------------------- |
2552| 201 | Permission denied.|
2553| 202 | Not system application.|
2554| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2555| 12300001 | The system service works abnormally. |
2556| 12300002 | Invalid challenge, authType or authTrustLevel. |
2557| 12300101 | The credential is incorrect. |
2558| 12300102 | Credential not enrolled. |
2559| 12300105 | The trust level is not supported. |
2560| 12300106 | The authentication type is not supported. |
2561| 12300109 | The authentication, enrollment, or update operation is canceled. |
2562| 12300110 | The authentication is locked. |
2563| 12300111 | The authentication time out. |
2564| 12300112 | The authentication service is busy. |
2565| 12300117 | PIN is expired. |
2566
2567**Example**
2568  ```ts
2569  let userAuth = new osAccount.UserAuth();
2570  let challenge: Uint8Array = new Uint8Array([0]);
2571  let authType: osAccount.AuthType = osAccount.AuthType.PIN;
2572  let authTrustLevel: osAccount.AuthTrustLevel = osAccount.AuthTrustLevel.ATL1;
2573  try {
2574    userAuth.auth(challenge, authType, authTrustLevel, {
2575      onResult: (result: number, extraInfo: osAccount.AuthResult) => {
2576          console.log('auth result = ' + result);
2577          console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
2578      }
2579    });
2580  } catch (e) {
2581    console.log('auth exception = ' + JSON.stringify(e));
2582  }
2583  ```
2584
2585### auth<sup>12+</sup>
2586
2587auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, options: AuthOptions, callback: IUserAuthCallback): Uint8Array
2588
2589Starts user authentication based on the specified challenge value, authentication type (PIN, facial, or fingerprint authentication), authentication trust level, and optional parameters (such as the account ID and authentication intent). This API uses an asynchronous callback to return the result.
2590
2591**System API**: This is a system API.
2592
2593**System capability**: SystemCapability.Account.OsAccount
2594
2595**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2596
2597**Parameters**
2598
2599| Name          | Type                                    | Mandatory| Description                               |
2600| --------------- | ---------------------------------------- | --- | ------------------------------------ |
2601| challenge       | Uint8Array                               | Yes | Challenge value, which is a random number used to prevent replay attacks and improve security.|
2602| authType        | [AuthType](#authtype8)                   | Yes | Authentication credential type.                       |
2603| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8)       | Yes | Trust level of the authentication result.              |
2604| options         | [AuthOptions](#authoptions12) | Yes| Optional parameters for the authentication.|
2605| callback        | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback used to return the authentication result. |
2606
2607**Return value**
2608
2609| Type       | Description              |
2610| ---------- | ------------------ |
2611| Uint8Array | ID of the context for canceling the authentication.|
2612
2613**Error codes**
2614
2615| ID| Error Message         |
2616| -------- | --------------------- |
2617| 201 | Permission denied.|
2618| 202 | Not system application.|
2619| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2620| 12300001 | The system service works abnormally. |
2621| 12300002 | Invalid challenge, authType, authTrustLevel or options. |
2622| 12300003 | Account not found. |
2623| 12300101 | The credential is incorrect. |
2624| 12300102 | Credential not enrolled. |
2625| 12300105 | The trust level is not supported. |
2626| 12300106 | The authentication type is not supported. |
2627| 12300109 | The authentication, enrollment, or update operation is canceled. |
2628| 12300110 | The authentication is locked. |
2629| 12300111 | The authentication time out. |
2630| 12300112 | The authentication service is busy. |
2631| 12300117 | PIN is expired. |
2632
2633**Example**
2634  ```ts
2635  let userAuth = new osAccount.UserAuth();
2636  let challenge: Uint8Array = new Uint8Array([0]);
2637  let authType: osAccount.AuthType = osAccount.AuthType.PIN;
2638  let authTrustLevel: osAccount.AuthTrustLevel = osAccount.AuthTrustLevel.ATL1;
2639  let options: osAccount.AuthOptions = {
2640    accountId: 100
2641  };
2642  try {
2643    userAuth.auth(challenge, authType, authTrustLevel, options, {
2644      onResult: (result: number, extraInfo: osAccount.AuthResult) => {
2645          console.log('auth result = ' + result);
2646          console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
2647      }
2648    });
2649  } catch (e) {
2650    console.log('auth exception = ' + JSON.stringify(e));
2651  }
2652  ```
2653
2654### authUser<sup>8+</sup>
2655
2656authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
2657
2658Performs authentication of the specified user. This API uses an asynchronous callback to return the result.
2659
2660**System API**: This is a system API.
2661
2662**System capability**: SystemCapability.Account.OsAccount
2663
2664**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2665
2666**Parameters**
2667
2668| Name          | Type                                                | Mandatory| Description                               |
2669| --------------- | ---------------------------------------------------- | --- | ------------------------------------ |
2670| userId          | number                                               | Yes | User ID.                       |
2671| challenge       | Uint8Array                                           | Yes | Challenge value, which is a random number used to improve security.                         |
2672| authType        | [AuthType](#authtype8)                   | Yes | Authentication credential type.                       |
2673| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8)       | Yes | Trust level of the authentication result.              |
2674| callback        | [IUserAuthCallback](#iuserauthcallback8) | Yes | Callback used to return the authentication result. |
2675
2676**Return value**
2677
2678| Type       | Description              |
2679| ---------- | ------------------ |
2680| Uint8Array | ID of the context for canceling the authentication.|
2681
2682**Error codes**
2683
2684| ID| Error Message         |
2685| -------- | --------------------- |
2686| 201 | Permission denied.|
2687| 202 | Not system application.|
2688| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2689| 12300001 | The system service works abnormally. |
2690| 12300002 | Invalid challenge, authType or authTrustLevel. |
2691| 12300101 | The credential is incorrect. |
2692| 12300102 | Credential not enrolled. |
2693| 12300003 | Account not found. |
2694| 12300105 | The trust level is not supported. |
2695| 12300106 | The authentication type is not supported. |
2696| 12300109 | The authentication, enrollment, or update operation is canceled. |
2697| 12300110 | The authentication is locked. |
2698| 12300111 | The authentication time out. |
2699| 12300112 | The authentication service is busy. |
2700| 12300117 | PIN is expired. |
2701
2702**Example**
2703  ```ts
2704  let userAuth = new osAccount.UserAuth();
2705  let userID: number = 100;
2706  let challenge: Uint8Array = new Uint8Array([0]);
2707  let authType: osAccount.AuthType = osAccount.AuthType.PIN;
2708  let authTrustLevel: osAccount.AuthTrustLevel = osAccount.AuthTrustLevel.ATL1;
2709  try {
2710    userAuth.authUser(userID, challenge, authType, authTrustLevel, {
2711      onResult: (result,extraInfo) => {
2712        console.log('authUser result = ' + result);
2713        console.log('authUser extraInfo = ' + JSON.stringify(extraInfo));
2714      }
2715    });
2716  } catch (e) {
2717    console.log('authUser exception = ' + JSON.stringify(e));
2718  }
2719  ```
2720
2721### cancelAuth<sup>8+</sup>
2722
2723cancelAuth(contextID: Uint8Array): void
2724
2725Cancels an authentication.
2726
2727**System API**: This is a system API.
2728
2729**System capability**: SystemCapability.Account.OsAccount
2730
2731**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
2732
2733**Parameters**
2734
2735| Name   | Type      | Mandatory | Description                                       |
2736| ----------| ---------- | ---- | ------------------------------------------ |
2737| contextId | Uint8Array | Yes  | ID of the authentication context. The context ID is dynamically generated.|
2738
2739**Error codes**
2740
2741| ID| Error Message           |
2742| -------- | ------------------ |
2743| 201 | Permission denied.|
2744| 202 | Not system application.|
2745| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2746| 12300001 | The system service works abnormally. |
2747| 12300002 | Invalid contextId. |
2748
2749**Example**
2750  ```ts
2751  let userAuth = new osAccount.UserAuth();
2752  let pinAuth: osAccount.PINAuth = new osAccount.PINAuth();
2753  let challenge = new Uint8Array([0]);
2754  let contextId: Uint8Array = userAuth.auth(challenge, osAccount.AuthType.PIN, osAccount.AuthTrustLevel.ATL1, {
2755    onResult: (result: number, extraInfo: osAccount.AuthResult) => {
2756      console.log('auth result = ' + result);
2757      console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
2758    }
2759  });
2760  try {
2761    userAuth.cancelAuth(contextId);
2762  } catch (e) {
2763    console.log('cancelAuth exception = ' + JSON.stringify(e));
2764  }
2765  ```
2766
2767## PINAuth<sup>8+</sup>
2768
2769Provides APIs for PIN authentication.
2770
2771**System API**: This is a system API.
2772
2773### constructor<sup>8+</sup>
2774
2775constructor()
2776
2777Creates a PIN authentication instance.
2778
2779**System API**: This is a system API.
2780
2781**System capability**: SystemCapability.Account.OsAccount
2782
2783**Error codes**
2784
2785| ID| Error Message      |
2786| -------- | ------------- |
2787| 202 | Not system application.|
2788
2789**Example**
2790  ```ts
2791  let pinAuth: osAccount.PINAuth = new osAccount.PINAuth();
2792  ```
2793
2794### registerInputer<sup>8+</sup>
2795
2796registerInputer(inputer: IInputer): void
2797
2798Registers a PIN inputer.
2799
2800**System API**: This is a system API.
2801
2802**System capability**: SystemCapability.Account.OsAccount
2803
2804**Required permissions**: ohos.permission.ACCESS_PIN_AUTH
2805
2806**Parameters**
2807
2808| Name   | Type                    | Mandatory| Description                     |
2809| ----------| ----------------------- | --- | -------------------------- |
2810| inputer   | [IInputer](#iinputer8)  | Yes | PIN inputer, which is used to obtain the PIN.|
2811
2812**Error codes**
2813
2814| ID| Error Message                    |
2815| -------- | --------------------------- |
2816| 201 | Permission denied.|
2817| 202 | Not system application.|
2818| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2819| 12300001 | The system service works abnormally. |
2820| 12300002 | Invalid inputer. |
2821| 12300103 | The credential inputer already exists. |
2822
2823**Example**
2824  ```ts
2825  let pinAuth: osAccount.PINAuth = new osAccount.PINAuth();
2826  let password = new Uint8Array([0, 0, 0, 0, 0]);
2827  try {
2828    pinAuth.registerInputer({
2829        onGetData: (authSubType: osAccount.AuthSubType, callback: osAccount.IInputData) => {
2830          callback.onSetData(authSubType, password);
2831        }
2832    });
2833    console.log('registerInputer success.');
2834  } catch (e) {
2835    console.log('registerInputer exception = ' + JSON.stringify(e));
2836  }
2837  ```
2838
2839### unregisterInputer<sup>8+</sup>
2840
2841unregisterInputer(): void
2842
2843Unregisters this PIN inputer.
2844
2845**System API**: This is a system API.
2846
2847**System capability**: SystemCapability.Account.OsAccount
2848
2849**Required permissions**: ohos.permission.ACCESS_PIN_AUTH
2850
2851**Error codes**
2852
2853| ID| Error Message                    |
2854| -------- | --------------------------- |
2855| 201 | Permission denied.|
2856| 202 | Not system application.|
2857
2858**Example**
2859  ```ts
2860  let pinAuth: osAccount.PINAuth = new osAccount.PINAuth();
2861  pinAuth.unregisterInputer();
2862  ```
2863
2864## InputerManager <sup>9+</sup>
2865
2866Provides APIs for managing credential inputers.
2867
2868### registerInputer<sup>9+</sup>
2869
2870static registerInputer(authType: AuthType, inputer: IInputer): void
2871
2872Registers a credential inputer.
2873
2874**System API**: This is a system API.
2875
2876**System capability**: SystemCapability.Account.OsAccount
2877
2878**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL or ohos.permission.MANAGE_USER_IDM
2879
2880**Parameters**
2881
2882| Name   | Type                    | Mandatory| Description                     |
2883| ----------| ----------------------- | --- | -------------------------- |
2884| authType   | [AuthType](#authtype8)  | Yes | Authentication credential type.|
2885| inputer   | [IInputer](#iinputer8)  | Yes | Credential inputer to register.|
2886
2887**Error codes**
2888
2889| ID| Error Message                    |
2890| -------- | --------------------------- |
2891| 201 | Permission denied.|
2892| 202 | Not system application.|
2893| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2894| 12300001 | The system service works abnormally. |
2895| 12300002 | Invalid authType or inputer. |
2896| 12300103 | The credential inputer already exists. |
2897| 12300106 | The authentication type is not supported. |
2898
2899**Example**
2900  ```ts
2901  let authType: osAccount.AuthType = osAccount.AuthType.DOMAIN;
2902  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0]);
2903  try {
2904    osAccount.InputerManager.registerInputer(authType, {
2905        onGetData: (authSubType: osAccount.AuthSubType, callback: osAccount.IInputData) => {
2906          callback.onSetData(authSubType, password);
2907        }
2908    });
2909    console.log('registerInputer success.');
2910  } catch (e) {
2911    console.log('registerInputer exception = ' + JSON.stringify(e));
2912  }
2913  ```
2914
2915### unregisterInputer<sup>9+</sup>
2916
2917static unregisterInputer(authType: AuthType): void
2918
2919Unregisters this credential inputer.
2920
2921**System API**: This is a system API.
2922
2923**System capability**: SystemCapability.Account.OsAccount
2924
2925**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL or ohos.permission.MANAGE_USER_IDM
2926
2927**Parameters**
2928
2929| Name   | Type                    | Mandatory| Description                     |
2930| ----------| ----------------------- | --- | -------------------------- |
2931| authType   | [AuthType](#authtype8)  | Yes | Authentication credential type.|
2932
2933**Error codes**
2934
2935| ID| Error Message                    |
2936| -------- | --------------------------- |
2937| 201 | Permission denied.|
2938| 202 | Not system application.|
2939| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
2940| 12300002  | Invalid authType. |
2941
2942**Example**
2943  ```ts
2944  let authType: osAccount.AuthType = osAccount.AuthType.DOMAIN;
2945  try {
2946    osAccount.InputerManager.unregisterInputer(authType);
2947    console.log('unregisterInputer success.');
2948  } catch(err) {
2949    console.log('unregisterInputer err:' + JSON.stringify(err));
2950  }
2951  ```
2952
2953## DomainPlugin<sup>9+</sup>
2954
2955Provides APIs for domain account authentication.
2956
2957**System API**: This is a system API.
2958
2959### auth<sup>9+</sup>
2960
2961auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUserAuthCallback): void
2962
2963Authenticates a domain account.
2964
2965**System API**: This is a system API.
2966
2967**System capability**: SystemCapability.Account.OsAccount
2968
2969**Parameters**
2970
2971| Name     | Type                                   | Mandatory| Description            |
2972| ---------- | --------------------------------------- | ---- | --------------- |
2973| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
2974| credential   | Uint8Array  | Yes  | Credentials of the domain account.|
2975| callback   | [IUserAuthCallback](#iuserauthcallback8)  | Yes  | Callback used to return the authentication result.|
2976
2977**Example**
2978  ```ts
2979  import { AsyncCallback } from '@kit.BasicServicesKit';
2980  let plugin: osAccount.DomainPlugin = {
2981    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
2982          callback: osAccount.IUserAuthCallback) => {
2983      // mock authentication
2984      // notify authentication result
2985      let result: osAccount.AuthResult = {
2986        token: new Uint8Array([0]),
2987        remainTimes: 5,
2988        freezingTime: 0
2989      };
2990      callback.onResult(0, result);
2991    },
2992    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
2993                    callback: osAccount.IUserAuthCallback) => {},
2994    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
2995                    callback: osAccount.IUserAuthCallback) => {},
2996    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
2997                    callback: AsyncCallback<osAccount.DomainAccountInfo>) => {},
2998    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
2999                      callback: AsyncCallback<osAccount.AuthStatusInfo>) => {},
3000    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3001                  callback: AsyncCallback<void>) => {},
3002    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
3003    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3004                          callback: AsyncCallback<boolean>) => {},
3005    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
3006  }
3007  osAccount.DomainAccountManager.registerPlugin(plugin);
3008  let userAuth = new osAccount.UserAuth();
3009  let challenge: Uint8Array = new Uint8Array([0]);
3010  let authType: osAccount.AuthType = osAccount.AuthType.DOMAIN;
3011  let authTrustLevel: osAccount.AuthTrustLevel = osAccount.AuthTrustLevel.ATL1;
3012  try {
3013    userAuth.auth(challenge, authType, authTrustLevel, {
3014      onResult: (resultCode: number, authResult: osAccount.AuthResult) => {
3015          console.log('auth resultCode = ' + resultCode);
3016          console.log('auth authResult = ' + JSON.stringify(authResult));
3017      }
3018    });
3019  } catch (err) {
3020    console.log('auth exception = ' + JSON.stringify(err));
3021  }
3022  ```
3023
3024### authWithPopup<sup>10+</sup>
3025
3026authWithPopup(domainAccountInfo: DomainAccountInfo, callback: IUserAuthCallback): void
3027
3028Authenticates a domain account in a pop-up window.
3029
3030**System API**: This is a system API.
3031
3032**System capability**: SystemCapability.Account.OsAccount
3033
3034**Parameters**
3035
3036| Name     | Type                                   | Mandatory| Description            |
3037| ---------- | --------------------------------------- | ---- | --------------- |
3038| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3039| callback   | [IUserAuthCallback](#iuserauthcallback8)  | Yes  | Callback used to return the authentication result.|
3040
3041**Example**
3042  ```ts
3043  import { AsyncCallback } from '@kit.BasicServicesKit';
3044  let plugin: osAccount.DomainPlugin = {
3045    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
3046          callback: osAccount.IUserAuthCallback) => {},
3047    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
3048                    callback: osAccount.IUserAuthCallback) => {
3049      // mock authentication
3050      // notify authentication result
3051      let result: osAccount.AuthResult = {
3052        token: new Uint8Array([0]),
3053        remainTimes: 5,
3054        freezingTime: 0
3055      };
3056      callback.onResult(0, result);
3057    },
3058    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3059                    callback: osAccount.IUserAuthCallback) => {},
3060    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
3061                    callback: AsyncCallback<osAccount.DomainAccountInfo>) => {},
3062    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
3063                        callback: AsyncCallback<osAccount.AuthStatusInfo>) => {},
3064    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3065                  callback: AsyncCallback<void>) => {},
3066    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
3067    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3068                          callback: AsyncCallback<boolean>) => {},
3069    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
3070  }
3071  osAccount.DomainAccountManager.registerPlugin(plugin)
3072  ```
3073
3074### authWithToken<sup>10+</sup>
3075
3076authWithToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: IUserAuthCallback): void
3077
3078Authenticates a domain account by the authorization token.
3079
3080**System API**: This is a system API.
3081
3082**System capability**: SystemCapability.Account.OsAccount
3083
3084**Parameters**
3085
3086| Name     | Type                                   | Mandatory| Description            |
3087| ---------- | --------------------------------------- | ---- | --------------- |
3088| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3089| token   | Uint8Array  | Yes  | Authorization token generated when the PIN or biometric authentication is successful.|
3090| callback   | [IUserAuthCallback](#iuserauthcallback8)  | Yes  | Callback used to return the authentication result.|
3091
3092**Example**
3093  ```ts
3094  import { AsyncCallback } from '@kit.BasicServicesKit';
3095  let plugin: osAccount.DomainPlugin = {
3096    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
3097          callback: osAccount.IUserAuthCallback) => {},
3098    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
3099                    callback: osAccount.IUserAuthCallback) => {},
3100    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3101                    callback: osAccount.IUserAuthCallback) => {
3102      // mock authentication
3103      // notify authentication result
3104      let result: osAccount.AuthResult = {
3105        token: new Uint8Array([0]),
3106        remainTimes: 5,
3107        freezingTime: 0
3108      };
3109      callback.onResult(0, result);
3110    },
3111    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
3112                    callback: AsyncCallback<osAccount.DomainAccountInfo>) => {},
3113    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
3114                        callback: AsyncCallback<osAccount.AuthStatusInfo>) => {},
3115    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3116                  callback: AsyncCallback<void>) => {},
3117    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
3118    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3119                          callback: AsyncCallback<boolean>) => {},
3120    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
3121  }
3122  osAccount.DomainAccountManager.registerPlugin(plugin)
3123  ```
3124
3125### getAccountInfo<sup>10+</sup>
3126
3127getAccountInfo(options: GetDomainAccountInfoPluginOptions, callback: AsyncCallback&lt;DomainAccountInfo&gt;): void
3128
3129Obtains information about a domain account.
3130
3131**System API**: This is a system API.
3132
3133**System capability**: SystemCapability.Account.OsAccount
3134
3135**Parameters**
3136
3137| Name     | Type                                   | Mandatory| Description            |
3138| ---------- | --------------------------------------- | ---- | --------------- |
3139| options   | [GetDomainAccountInfoPluginOptions](#getdomainaccountinfopluginoptions10)  | Yes  | Domain account information.|
3140| callback   | AsyncCallback&lt;[DomainAccountInfo](#domainaccountinfo8)&gt; | Yes  | Callback used to return the result.|
3141
3142**Example**
3143  ```ts
3144  import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
3145  let plugin: osAccount.DomainPlugin = {
3146    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
3147          callback: osAccount.IUserAuthCallback) => {},
3148    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
3149                    callback: osAccount.IUserAuthCallback) => {},
3150    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3151                    callback: osAccount.IUserAuthCallback) => {},
3152    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
3153                    callback: AsyncCallback<osAccount.DomainAccountInfo>) => {
3154      // mock getting account information
3155      // notify result
3156      let code: BusinessError = {
3157        code: 0,
3158        name: "",
3159        message: ""
3160      };
3161      let accountInfo: osAccount.DomainAccountInfo = {
3162        domain: options.domain ? options.domain : "",
3163        accountName: options.accountName,
3164        accountId: 'xxxx'
3165      };
3166      callback(code, accountInfo);
3167    },
3168    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
3169                        callback: AsyncCallback<osAccount.AuthStatusInfo>) => {},
3170    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3171                  callback: AsyncCallback<void>) => {},
3172    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
3173    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3174                          callback: AsyncCallback<boolean>) => {},
3175    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
3176  }
3177  osAccount.DomainAccountManager.registerPlugin(plugin)
3178  ```
3179
3180### getAuthStatusInfo<sup>10+</sup>
3181
3182getAuthStatusInfo(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback&lt;AuthStatusInfo&gt;): void
3183
3184Obtains the authentication status of a domain account.
3185
3186**System API**: This is a system API.
3187
3188**System capability**: SystemCapability.Account.OsAccount
3189
3190**Parameters**
3191
3192| Name     | Type                                   | Mandatory| Description            |
3193| ---------- | --------------------------------------- | ---- | --------------- |
3194| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3195| callback   | AsyncCallback&lt;[AuthStatusInfo](#authstatusinfo10)&gt; | Yes  | Callback used to return the result.|
3196
3197**Example**
3198  ```ts
3199  import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
3200  let plugin: osAccount.DomainPlugin = {
3201    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
3202          callback: osAccount.IUserAuthCallback) => {},
3203    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
3204                    callback: osAccount.IUserAuthCallback) => {},
3205    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3206                    callback: osAccount.IUserAuthCallback) => {},
3207    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
3208                    callback: AsyncCallback<osAccount.DomainAccountInfo>) => {},
3209    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
3210                        callback: AsyncCallback<osAccount.AuthStatusInfo>) => {
3211      let code: BusinessError = {
3212        code: 0,
3213        name: "",
3214        message: ""
3215      };
3216      let statusInfo: osAccount.AuthStatusInfo = {
3217        remainTimes: 5,
3218        freezingTime: 0
3219      };
3220      callback(code, statusInfo);
3221    },
3222    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3223                  callback: AsyncCallback<void>) => {},
3224    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
3225    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3226                          callback: AsyncCallback<boolean>) => {},
3227    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
3228  }
3229  osAccount.DomainAccountManager.registerPlugin(plugin)
3230  ```
3231
3232### bindAccount<sup>10+</sup>
3233
3234bindAccount(domainAccountInfo: DomainAccountInfo, localId: number, callback: AsyncCallback&lt;void&gt;): void
3235
3236Binds a domain account.
3237
3238**System API**: This is a system API.
3239
3240**System capability**: SystemCapability.Account.OsAccount
3241
3242**Parameters**
3243
3244| Name     | Type                                   | Mandatory| Description            |
3245| ---------- | --------------------------------------- | ---- | --------------- |
3246| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3247| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
3248
3249**Example**
3250  ```ts
3251  import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
3252  let plugin: osAccount.DomainPlugin = {
3253    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
3254          callback: osAccount.IUserAuthCallback) => {},
3255    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
3256                    callback: osAccount.IUserAuthCallback) => {},
3257    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3258                    callback: osAccount.IUserAuthCallback) => {},
3259    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
3260                    callback: AsyncCallback<osAccount.DomainAccountInfo>) => {},
3261    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
3262                        callback: AsyncCallback<osAccount.AuthStatusInfo>) => {},
3263    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3264                  callback: AsyncCallback<void>) => {
3265      // mock unbinding operation
3266      // notify binding result
3267      let code: BusinessError = {
3268        code: 0,
3269        name: "",
3270        message: ""
3271      };
3272      callback(code);
3273    },
3274    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
3275    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3276                          callback: AsyncCallback<boolean>) => {},
3277    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
3278  }
3279  osAccount.DomainAccountManager.registerPlugin(plugin)
3280  ```
3281
3282### unbindAccount<sup>10+</sup>
3283
3284unbindAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback&lt;void&gt;): void
3285
3286Unbinds a domain account.
3287
3288**System API**: This is a system API.
3289
3290**System capability**: SystemCapability.Account.OsAccount
3291
3292**Parameters**
3293
3294| Name     | Type                                   | Mandatory| Description            |
3295| ---------- | --------------------------------------- | ---- | --------------- |
3296| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3297| callback   | AsyncCallback&lt;void&gt; | Yes  | Callback used to return the result.|
3298
3299**Example**
3300  ```ts
3301  import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
3302  let plugin: osAccount.DomainPlugin = {
3303    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
3304          callback: osAccount.IUserAuthCallback) => {},
3305    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
3306                    callback: osAccount.IUserAuthCallback) => {},
3307    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3308                    callback: osAccount.IUserAuthCallback) => {},
3309    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
3310                    callback: AsyncCallback<osAccount.DomainAccountInfo>) => {},
3311    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
3312                        callback: AsyncCallback<osAccount.AuthStatusInfo>) => {},
3313    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3314                  callback: AsyncCallback<void>) => {},
3315    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {
3316      // mock unbinding operation
3317      // notify unbinding result
3318      let code: BusinessError = {
3319        code: 0,
3320        name: "",
3321        message: ""
3322      };
3323      callback(code);
3324    },
3325    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3326                          callback: AsyncCallback<boolean>) => {},
3327    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
3328  }
3329  osAccount.DomainAccountManager.registerPlugin(plugin)
3330  ```
3331
3332### isAccountTokenValid<sup>10+</sup>
3333
3334isAccountTokenValid(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: AsyncCallback&lt;boolean&gt;): void
3335
3336Checks whether the specified domain account token is valid.
3337
3338**System API**: This is a system API.
3339
3340**System capability**: SystemCapability.Account.OsAccount
3341
3342**Parameters**
3343
3344| Name     | Type                                   | Mandatory| Description            |
3345| ---------- | --------------------------------------- | ---- | --------------- |
3346| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3347| token | Uint8Array | Yes| Domain account token to check.|
3348| callback   | AsyncCallback&lt;boolean&gt; | Yes  | Callback used to return the result.|
3349
3350**Example**
3351  ```ts
3352  import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
3353  let plugin: osAccount.DomainPlugin = {
3354    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
3355          callback: osAccount.IUserAuthCallback) => {},
3356    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
3357                    callback: osAccount.IUserAuthCallback) => {},
3358    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3359                    callback: osAccount.IUserAuthCallback) => {},
3360    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
3361                    callback: AsyncCallback<osAccount.DomainAccountInfo>) => {},
3362    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
3363                        callback: AsyncCallback<osAccount.AuthStatusInfo>) => {},
3364    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3365                  callback: AsyncCallback<void>) => {},
3366    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
3367    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3368                          callback: AsyncCallback<boolean>) => {
3369      // mock checking operation
3370      // notify checking result
3371      let code: BusinessError = {
3372        code: 0,
3373        name: "",
3374        message: ""
3375      };
3376      callback(code, true);
3377    },
3378    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
3379  }
3380  osAccount.DomainAccountManager.registerPlugin(plugin)
3381  ```
3382
3383### getAccessToken<sup>10+</sup>
3384
3385getAccessToken(options: GetDomainAccessTokenOptions, callback: AsyncCallback&lt;Uint8Array&gt;): void
3386
3387Obtains the domain access token based on the specified conditions.
3388
3389**System API**: This is a system API.
3390
3391**System capability**: SystemCapability.Account.OsAccount
3392
3393**Parameters**
3394
3395| Name     | Type                                   | Mandatory| Description            |
3396| ---------- | --------------------------------------- | ---- | --------------- |
3397| options | [GetDomainAccessTokenOptions](#getdomainaccesstokenoptions10)  | Yes  | Options specified for obtaining the domain access token.|
3398| callback   | AsyncCallback&lt;Uint8Array&gt; | Yes  | Callback used to return the result.|
3399
3400**Example**
3401  ```ts
3402  import { AsyncCallback, BusinessError } from '@kit.BasicServicesKit';
3403  let plugin: osAccount.DomainPlugin = {
3404    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
3405          callback: osAccount.IUserAuthCallback) => {},
3406    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
3407                    callback: osAccount.IUserAuthCallback) => {},
3408    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3409                    callback: osAccount.IUserAuthCallback) => {},
3410    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
3411                    callback: AsyncCallback<osAccount.DomainAccountInfo>) => {},
3412    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
3413                        callback: AsyncCallback<osAccount.AuthStatusInfo>) => {},
3414    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3415                  callback: AsyncCallback<void>) => {},
3416    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
3417    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3418                          callback: AsyncCallback<boolean>) => {},
3419    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {
3420      // mock getting operation
3421      // notify result
3422      let code: BusinessError = {
3423        code: 0,
3424        name: "",
3425        message: ""
3426      };
3427      let token: Uint8Array = new Uint8Array([0]);
3428      callback(code, token);
3429    }
3430  }
3431  osAccount.DomainAccountManager.registerPlugin(plugin)
3432  ```
3433
3434## DomainAccountManager <sup>9+</sup>
3435Provides APIs for domain account management.
3436
3437### registerPlugin<sup>9+</sup>
3438
3439static registerPlugin(plugin: DomainPlugin): void
3440
3441Registers a domain plug-in.
3442
3443**System API**: This is a system API.
3444
3445**System capability**: SystemCapability.Account.OsAccount
3446
3447**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
3448
3449**Parameters**
3450
3451| Name   | Type                    | Mandatory| Description                     |
3452| ----------| ----------------------- | --- | -------------------------- |
3453| plugin   | [DomainPlugin](#domainplugin9)  | Yes | Domain plug-in to register.|
3454
3455**Error codes**
3456
3457| ID| Error Message                    |
3458| -------- | --------------------------- |
3459| 201 | Permission denied.|
3460| 202 | Not system application.|
3461| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3462| 12300201 | The domain plugin has been registered. |
3463
3464**Example**
3465  ```ts
3466  import { AsyncCallback } from '@kit.BasicServicesKit';
3467  let plugin: osAccount.DomainPlugin = {
3468    auth: (domainAccountInfo: osAccount.DomainAccountInfo, credential: Uint8Array,
3469         callback: osAccount.IUserAuthCallback) => {},
3470    authWithPopup: (domainAccountInfo: osAccount.DomainAccountInfo,
3471                  callback: osAccount.IUserAuthCallback) => {},
3472    authWithToken: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3473                  callback: osAccount.IUserAuthCallback) => {},
3474    getAccountInfo: (options: osAccount.GetDomainAccountInfoPluginOptions,
3475                   callback: AsyncCallback<osAccount.DomainAccountInfo>) => {},
3476    getAuthStatusInfo: (domainAccountInfo: osAccount.DomainAccountInfo,
3477                        callback: AsyncCallback<osAccount.AuthStatusInfo>) => {},
3478    bindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, localId: number,
3479                  callback: AsyncCallback<void>) => {},
3480    unbindAccount: (domainAccountInfo: osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
3481    isAccountTokenValid: (domainAccountInfo: osAccount.DomainAccountInfo, token: Uint8Array,
3482                        callback: AsyncCallback<boolean>) => {},
3483    getAccessToken: (options: osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
3484  }
3485  try {
3486    osAccount.DomainAccountManager.registerPlugin(plugin);
3487    console.log('registerPlugin success.');
3488  } catch(err) {
3489    console.log('registerPlugin err:' + JSON.stringify(err));
3490  }
3491  ```
3492
3493### unregisterPlugin<sup>9+</sup>
3494
3495static unregisterPlugin(): void
3496
3497Unregisters this domain plug-in.
3498
3499**System API**: This is a system API.
3500
3501**System capability**: SystemCapability.Account.OsAccount
3502
3503**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
3504
3505**Error codes**
3506
3507| ID| Error Message                    |
3508| -------- | --------------------------- |
3509| 201 | Permission denied.|
3510| 202 | Not system application.|
3511
3512**Example**
3513  ```ts
3514  try {
3515    osAccount.DomainAccountManager.unregisterPlugin();
3516    console.log('unregisterPlugin success.');
3517  } catch(err) {
3518    console.log('unregisterPlugin err:' + JSON.stringify(err));
3519  }
3520  ```
3521
3522### auth<sup>10+</sup>
3523
3524auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUserAuthCallback): void
3525
3526Authenticates a domain account.
3527
3528**System API**: This is a system API.
3529
3530**System capability**: SystemCapability.Account.OsAccount
3531
3532**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
3533
3534**Parameters**
3535
3536| Name     | Type                                   | Mandatory| Description            |
3537| ---------- | --------------------------------------- | ---- | --------------- |
3538| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3539| credential   | Uint8Array  | Yes  | Credentials of the domain account.|
3540| callback   | [IUserAuthCallback](#iuserauthcallback8)  | Yes  | Callback used to return the authentication result.|
3541
3542**Error codes**
3543
3544| ID| Error Message                    |
3545| -------- | --------------------------- |
3546| 201 | Permission denied.|
3547| 202 | Not system application.|
3548| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3549| 801 | Capability not supported.|
3550| 12300001 | The system service works abnormally. |
3551| 12300002 | Invalid domainAccountInfo or credential. |
3552| 12300003 | Domain account does not exist. |
3553| 12300013 | Network exception. |
3554| 12300101 | Authentication failed. |
3555| 12300109 | The authentication, enrollment, or update operation is canceled. |
3556| 12300110 | The authentication is locked. |
3557| 12300111 | The authentication time out. |
3558| 12300112 | The authentication service is busy. |
3559| 12300113 | The account authentication service does not exist. |
3560| 12300114 | The account authentication service works abnormally. |
3561
3562**Example**
3563  ```ts
3564  let domainAccountInfo: osAccount.DomainAccountInfo = {
3565    domain: 'CHINA',
3566    accountName: 'zhangsan'
3567  }
3568  let credential = new Uint8Array([0])
3569  try {
3570    osAccount.DomainAccountManager.auth(domainAccountInfo, credential, {
3571      onResult: (resultCode: number, authResult: osAccount.AuthResult) => {
3572        console.log('auth resultCode = ' + resultCode);
3573        console.log('auth authResult = ' + JSON.stringify(authResult));
3574      }
3575    });
3576  } catch (err) {
3577    console.log('auth exception = ' + JSON.stringify(err));
3578  }
3579  ```
3580
3581### authWithPopup<sup>10+</sup>
3582
3583authWithPopup(callback: IUserAuthCallback): void
3584
3585Authenticates this domain account in a pop-up window.
3586
3587**System API**: This is a system API.
3588
3589**System capability**: SystemCapability.Account.OsAccount
3590
3591**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
3592
3593No permission is required since API version 11. Use the SDK of the latest version.
3594
3595**Parameters**
3596
3597| Name     | Type                                   | Mandatory| Description            |
3598| ---------- | --------------------------------------- | ---- | --------------- |
3599| callback   | [IUserAuthCallback](#iuserauthcallback8)  | Yes  | Callback used to return the authentication result.|
3600
3601**Error codes**
3602
3603| ID| Error Message                    |
3604| -------- | --------------------------- |
3605| 201 | Permission denied.|
3606| 202 | Not system application.|
3607| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3608| 801 | Capability not supported.|
3609| 12300001 | The system service works abnormally. |
3610| 12300003 | No domain account is bound. |
3611| 12300013 | Network exception. |
3612| 12300101 | Authentication failed. |
3613| 12300109 | The authentication, enrollment, or update operation is canceled. |
3614| 12300110 | The authentication is locked. |
3615| 12300111 | The authentication time out. |
3616| 12300112 | The authentication service is busy. |
3617| 12300113 | The account authentication service does not exist. |
3618| 12300114 | The account authentication service works abnormally. |
3619
3620**Example**
3621  ```ts
3622  try {
3623    osAccount.DomainAccountManager.authWithPopup({
3624      onResult: (resultCode: number, authResult: osAccount.AuthResult) => {
3625        console.log('auth resultCode = ' + resultCode);
3626        console.log('auth authResult = ' + JSON.stringify(authResult));
3627      }
3628    })
3629  } catch (err) {
3630    console.log('auth exception = ' + JSON.stringify(err));
3631  }
3632  ```
3633
3634### authWithPopup<sup>10+</sup>
3635
3636authWithPopup(localId: number, callback: IUserAuthCallback): void
3637
3638Authenticates a domain account in a pop-up window.
3639
3640**System API**: This is a system API.
3641
3642**System capability**: SystemCapability.Account.OsAccount
3643
3644**Required permissions**: ohos.permission.ACCESS_USER_AUTH_INTERNAL
3645
3646No permission is required since API version 11. Use the SDK of the latest version.
3647
3648**Parameters**
3649
3650| Name     | Type                                   | Mandatory| Description            |
3651| ---------- | --------------------------------------- | ---- | --------------- |
3652| localId   | number  | Yes  | Local ID of the system account bound to the domain account.|
3653| callback   | [IUserAuthCallback](#iuserauthcallback8)  | Yes  | Callback used to return the authentication result.|
3654
3655**Error codes**
3656
3657| ID| Error Message                    |
3658| -------- | --------------------------- |
3659| 201 | Permission denied.|
3660| 202 | Not system application.|
3661| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3662| 801 | Capability not supported.|
3663| 12300001 | The system service works abnormally. |
3664| 12300002 | Invalid localId. |
3665| 12300003 | No domain account is bound. |
3666| 12300013 | Network exception. |
3667| 12300101 | Authentication failed. |
3668| 12300109 | The authentication, enrollment, or update operation is canceled. |
3669| 12300110 | The authentication is locked. |
3670| 12300111 | The authentication time out. |
3671| 12300112 | The authentication service is busy. |
3672| 12300113 | The account authentication service does not exist. |
3673| 12300114 | The account authentication service works abnormally. |
3674
3675**Example**
3676  ```ts
3677  try {
3678    osAccount.DomainAccountManager.authWithPopup(100, {
3679      onResult: (resultCode: number, authResult: osAccount.AuthResult) => {
3680        console.log('authWithPopup resultCode = ' + resultCode);
3681        console.log('authWithPopup authResult = ' + JSON.stringify(authResult));
3682      }
3683    })
3684  } catch (err) {
3685    console.log('authWithPopup exception = ' + JSON.stringify(err));
3686  }
3687  ```
3688
3689### hasAccount<sup>10+</sup>
3690
3691hasAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback&lt;boolean&gt;): void
3692
3693Checks whether a domain account exists.
3694
3695**System API**: This is a system API.
3696
3697**System capability**: SystemCapability.Account.OsAccount
3698
3699**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
3700
3701**Parameters**
3702
3703| Name     | Type                                   | Mandatory| Description            |
3704| ---------- | --------------------------------------- | ---- | --------------- |
3705| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3706| callback   | AsyncCallback&lt;boolean&gt;  | Yes  | Callback used to return the result.|
3707
3708**Error codes**
3709
3710| ID| Error Message                    |
3711| -------- | --------------------------- |
3712| 201 | Permission denied.|
3713| 202 | Not system application.|
3714| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3715| 801 | Capability not supported.|
3716| 12300001 | The system service works abnormally. |
3717| 12300002 | Invalid domainAccountInfo. |
3718| 12300013 | Network exception. |
3719| 12300111 | The authentication time out. |
3720
3721**Example**
3722  ```ts
3723  import { BusinessError } from '@kit.BasicServicesKit';
3724  let domainAccountInfo: osAccount.DomainAccountInfo = {
3725    domain: 'CHINA',
3726    accountName: 'zhangsan'
3727  }
3728  try {
3729    osAccount.DomainAccountManager.hasAccount(domainAccountInfo, (err: BusinessError, result: boolean) => {
3730      if (err) {
3731        console.log('call hasAccount failed, error: ' + JSON.stringify(err));
3732      } else {
3733        console.log('hasAccount result: ' + result);
3734      }
3735    });
3736  } catch (err) {
3737    console.log('hasAccount exception = ' + JSON.stringify(err));
3738  }
3739  ```
3740
3741### hasAccount<sup>10+</sup>
3742
3743hasAccount(domainAccountInfo: DomainAccountInfo): Promise&lt;boolean&gt;
3744
3745Checks whether a domain account exists.
3746
3747**System API**: This is a system API.
3748
3749**System capability**: SystemCapability.Account.OsAccount
3750
3751**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
3752
3753**Parameters**
3754
3755| Name     | Type                                   | Mandatory| Description            |
3756| ---------- | --------------------------------------- | ---- | --------------- |
3757| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3758
3759**Return value**
3760
3761| Type                     | Description                    |
3762| :------------------------ | ----------------------- |
3763| Promise&lt;boolean&gt; | Promise used to return the result.|
3764
3765**Error codes**
3766
3767| ID| Error Message                    |
3768| -------- | --------------------------- |
3769| 201 | Permission denied.|
3770| 202 | Not system application.|
3771| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3772| 801 | Capability not supported.|
3773| 12300001 | The system service works abnormally. |
3774| 12300002 | Invalid domainAccountInfo. |
3775| 12300013 | Network exception. |
3776| 12300111 | The authentication time out. |
3777
3778**Example**
3779  ```ts
3780  import { BusinessError } from '@kit.BasicServicesKit';
3781  let domainAccountInfo: osAccount.DomainAccountInfo = {
3782    domain: 'CHINA',
3783    accountName: 'zhangsan'
3784  }
3785  try {
3786    osAccount.DomainAccountManager.hasAccount(domainAccountInfo).then((result: boolean) => {
3787      console.log('hasAccount result: ' + result);
3788    }).catch((err: BusinessError) => {
3789        console.log('call hasAccount failed, error: ' + JSON.stringify(err));
3790    });
3791  } catch (err) {
3792    console.log('hasAccount exception = ' + JSON.stringify(err));
3793  }
3794  ```
3795
3796### updateAccountToken<sup>10+</sup>
3797
3798updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: AsyncCallback&lt;void&gt;): void
3799
3800Updates the token of a domain account. An empty token means an invalid token. This API uses an asynchronous callback to return the result.
3801
3802**System API**: This is a system API.
3803
3804**System capability**: SystemCapability.Account.OsAccount
3805
3806**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
3807
3808**Parameters**
3809
3810| Name     | Type                                   | Mandatory| Description            |
3811| ---------- | --------------------------------------- | ---- | --------------- |
3812| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3813| token | Uint8Array  | Yes  | New domain account token.|
3814| callback | AsyncCallback&lt;void&gt; | Yes| Callback used to return the result. If the token is successfully updated, **err** is **null**. Otherwise, **err** is an error object.|
3815
3816**Error codes**
3817
3818| ID| Error Message                    |
3819| -------- | --------------------------- |
3820| 201 | Permission denied.|
3821| 202 | Not system application.|
3822| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3823| 12300001 | The system service works abnormally. |
3824| 12300002 | Invalid token. |
3825| 12300003 | Account not found. |
3826
3827**Example**
3828  ```ts
3829  import { BusinessError } from '@kit.BasicServicesKit';
3830  let domainAccountInfo: osAccount.DomainAccountInfo = {
3831    domain: 'CHINA',
3832    accountName: 'zhangsan',
3833    accountId: '123456'
3834  }
3835  let token = new Uint8Array([0])
3836  try {
3837    osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token, (err: BusinessError) => {
3838      if (err != null) {
3839        console.log('updateAccountToken failed, error: ' + JSON.stringify(err));
3840      } else {
3841        console.log('updateAccountToken successfully');
3842      }
3843    })
3844  } catch (err) {
3845    console.log('updateAccountToken exception = ' + JSON.stringify(err));
3846  }
3847  ```
3848
3849### updateAccountToken<sup>10+</sup>
3850
3851updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array): Promise&lt;void&gt;
3852
3853Updates the token of a domain account. An empty token means an invalid token. This API uses a promise to return the result.
3854
3855**System API**: This is a system API.
3856
3857**System capability**: SystemCapability.Account.OsAccount
3858
3859**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
3860
3861**Parameters**
3862
3863| Name     | Type                                   | Mandatory| Description            |
3864| ---------- | --------------------------------------- | ---- | --------------- |
3865| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3866| token | Uint8Array  | Yes  | New domain account token.|
3867
3868**Return value**
3869
3870| Type                     | Description                    |
3871| :------------------------ | ----------------------- |
3872| Promise&lt;void&gt; | Promise that returns no value.|
3873
3874**Error codes**
3875
3876| ID| Error Message                    |
3877| -------- | --------------------------- |
3878| 201 | Permission denied.|
3879| 202 | Not system application.|
3880| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3881| 12300001 | The system service works abnormally. |
3882| 12300002 | Invalid token. |
3883| 12300003 | Account not found. |
3884
3885**Example**
3886  ```ts
3887  import { BusinessError } from '@kit.BasicServicesKit';
3888  let domainAccountInfo: osAccount.DomainAccountInfo = {
3889    domain: 'CHINA',
3890    accountName: 'zhangsan',
3891    accountId: '123456'
3892  }
3893  let token = new Uint8Array([0])
3894  try {
3895    osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token).then(() => {
3896      console.log('updateAccountToken successfully');
3897    }).catch((err: BusinessError) => {
3898        console.log('updateAccountToken failed, error: ' + JSON.stringify(err));
3899    });
3900  } catch (err) {
3901    console.log('updateAccountToken exception = ' + JSON.stringify(err));
3902  }
3903  ```
3904
3905### updateAccountInfo<sup>12+</sup>
3906
3907updateAccountInfo(oldAccountInfo: DomainAccountInfo, newAccountInfo: DomainAccountInfo): Promise&lt;void&gt;
3908
3909Updates information of a domain account. This API uses a promise to return the result.
3910
3911**System API**: This is a system API.
3912
3913**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
3914
3915**System capability**: SystemCapability.Account.OsAccount
3916
3917**Parameters**
3918
3919| Name     | Type                                   | Mandatory| Description            |
3920| ---------- | --------------------------------------- | ---- | --------------- |
3921| oldAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
3922| newAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | New domain account information.|
3923
3924**Error codes**
3925
3926| ID| Error Message                    |
3927| -------- | --------------------------- |
3928| 201 | Permission denied.|
3929| 202 | Not system application.|
3930| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3931| 801 | Capability not supported.|
3932| 12300001 | The system service works abnormally. |
3933| 12300002 | The new account info is invalid. |
3934| 12300003 | The old account not found. |
3935| 12300004 | The new account already exists. |
3936
3937**Example**
3938  ```ts
3939  import { BusinessError } from '@kit.BasicServicesKit';
3940  let oldDomainInfo: osAccount.DomainAccountInfo =
3941    {domain: 'testDomain', accountName: 'oldtestAccountName'};
3942  let newDomainInfo: osAccount.DomainAccountInfo =
3943    {domain: 'testDomain', accountName: 'newtestAccountName'};
3944  try {
3945    osAccount.DomainAccountManager.updateAccountInfo(oldDomainInfo, newDomainInfo).then(() => {
3946      console.log('updateAccountInfo, success');
3947    }).catch((err: BusinessError) => {
3948      console.log('updateAccountInfo err: ' + err);
3949    });
3950  } catch (e) {
3951    console.log('updateAccountInfo exception: ' + e);
3952  }
3953  ```
3954
3955### getAccountInfo<sup>10+</sup>
3956
3957getAccountInfo(options: GetDomainAccountInfoOptions, callback: AsyncCallback&lt;DomainAccountInfo&gt;): void
3958
3959Obtains information about the specified domain account. This API uses an asynchronous callback to return the result.
3960
3961**System API**: This is a system API.
3962
3963**System capability**: SystemCapability.Account.OsAccount
3964
3965**Required permissions**: ohos.permission.GET_DOMAIN_ACCOUNTS
3966
3967**Parameters**
3968
3969| Name     | Type                                   | Mandatory| Description            |
3970| ---------- | --------------------------------------- | ---- | --------------- |
3971| options   | [GetDomainAccountInfoOptions](#getdomainaccountinfooptions10)  | Yes  | Domain account information.|
3972| callback   | AsyncCallback&lt;DomainAccountInfo&gt;  | Yes  | Callback used to return the result.|
3973
3974**Error codes**
3975
3976| ID| Error Message                    |
3977| -------- | --------------------------- |
3978| 201 | Permission denied.|
3979| 202 | Not system application.|
3980| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
3981| 801 | Capability not supported.|
3982| 12300001 | The system service works abnormally. |
3983| 12300003 | Account not found. |
3984| 12300013 | Network exception. |
3985| 12300111 | The authentication time out. |
3986
3987**Example**
3988  ```ts
3989  import { BusinessError } from '@kit.BasicServicesKit';
3990  let domainAccountInfo: osAccount.GetDomainAccountInfoOptions = {
3991    domain: 'CHINA',
3992    accountName: 'zhangsan'
3993  }
3994  try {
3995    osAccount.DomainAccountManager.getAccountInfo(domainAccountInfo,
3996      (err: BusinessError, result: osAccount.DomainAccountInfo) => {
3997      if (err) {
3998        console.log('call getAccountInfo failed, error: ' + JSON.stringify(err));
3999      } else {
4000        console.log('getAccountInfo result: ' + result);
4001      }
4002    });
4003  } catch (err) {
4004    console.log('getAccountInfo exception = ' + JSON.stringify(err));
4005  }
4006  ```
4007
4008### getAccountInfo<sup>10+</sup>
4009
4010getAccountInfo(options: GetDomainAccountInfoOptions): Promise&lt;DomainAccountInfo&gt;
4011
4012Obtains information about the specified domain account. This API uses a promise to return the result.
4013
4014**System API**: This is a system API.
4015
4016**System capability**: SystemCapability.Account.OsAccount
4017
4018**Required permissions**: ohos.permission.GET_DOMAIN_ACCOUNTS
4019
4020**Parameters**
4021
4022| Name     | Type                                   | Mandatory| Description            |
4023| ---------- | --------------------------------------- | ---- | --------------- |
4024| options   | [GetDomainAccountInfoOptions](#getdomainaccountinfooptions10)  | Yes  | Domain account information.|
4025
4026**Return value**
4027
4028| Type                     | Description                    |
4029| :------------------------ | ----------------------- |
4030| Promise&lt;DomainAccountInfo&gt; | Promise used to return the domain account information obtained.|
4031
4032**Error codes**
4033
4034| ID| Error Message                    |
4035| -------- | --------------------------- |
4036| 201 | Permission denied.|
4037| 202 | Not system application.|
4038| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4039| 801 | Capability not supported.|
4040| 12300001 | The system service works abnormally. |
4041| 12300003 | Account not found. |
4042| 12300013 | Network exception. |
4043| 12300111 | The authentication time out. |
4044
4045**Example**
4046  ```ts
4047  import { BusinessError } from '@kit.BasicServicesKit';
4048  let domainAccountInfo: osAccount.GetDomainAccountInfoOptions = {
4049    domain: 'CHINA',
4050    accountName: 'zhangsan'
4051  }
4052  try {
4053    osAccount.DomainAccountManager.getAccountInfo(domainAccountInfo)
4054      .then((result: osAccount.DomainAccountInfo) => {
4055      console.log('getAccountInfo result: ' + result);
4056    }).catch((err: BusinessError) => {
4057      console.log('call getAccountInfo failed, error: ' + JSON.stringify(err));
4058    });
4059  } catch (err) {
4060    console.log('getAccountInfo exception = ' + JSON.stringify(err));
4061  }
4062  ```
4063
4064### getAccessToken<sup>11+</sup>
4065
4066getAccessToken(businessParams: Record<string, Object>, callback: AsyncCallback&lt;Uint8Array&gt;): void
4067
4068Obtains the service access token of this domain account. This API uses an asynchronous callback to return the result.
4069
4070**System API**: This is a system API.
4071
4072**System capability**: SystemCapability.Account.OsAccount
4073
4074**Parameters**
4075
4076| Name     | Type                                   | Mandatory| Description            |
4077| ---------- | --------------------------------------- | ---- | --------------- |
4078| businessParams | Record<string, Object>  | Yes  | Service parameters. The specific formats vary depending on the domain plug-in.|
4079| callback | AsyncCallback&lt;Uint8Array&gt;  | Yes  | Callback used to return the result. If the operation is successful, **err** is **null**. Otherwise, an error object is returned.|
4080
4081**Error codes**
4082
4083| ID| Error Message                    |
4084| -------- | --------------------------- |
4085| 202 | Not system application.|
4086| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4087| 801 | Capability not supported.|
4088| 12300001 | The system service works abnormally. |
4089| 12300002 | Invalid business parameters. |
4090| 12300003 | Domain account not found. |
4091| 12300013 | Network exception. |
4092| 12300014 | The domain account is not authenticated. |
4093| 12300111 | The authentication time out. |
4094
4095**Example**
4096  ```ts
4097  import { BusinessError } from '@kit.BasicServicesKit';
4098  let businessParams: Record<string, Object> = {
4099    'clientId': 'xxx',
4100    'secretId': 'yyy'
4101  };  // depends on the implementation of the domain plugin
4102  try {
4103    osAccount.DomainAccountManager.getAccessToken(businessParams,
4104      (err: BusinessError, result: Uint8Array) => {
4105      if (err) {
4106        console.log('getAccessToken failed, error: ' + JSON.stringify(err));
4107      } else {
4108        console.log('getAccessToken result: ' + result);
4109      }
4110    });
4111  } catch (err) {
4112    console.log('getAccessToken exception = ' + JSON.stringify(err));
4113  }
4114  ```
4115
4116### getAccessToken<sup>11+</sup>
4117
4118getAccessToken(businessParams: Record<string, Object>): Promise&lt;Uint8Array&gt;
4119
4120Obtains the service access token of this domain account. This API uses a promise to return the result.
4121
4122**System API**: This is a system API.
4123
4124**System capability**: SystemCapability.Account.OsAccount
4125
4126**Parameters**
4127
4128| Name     | Type                                   | Mandatory| Description            |
4129| ---------- | --------------------------------------- | ---- | --------------- |
4130| businessParams | Record<string, Object> | Yes  | Service parameters. The specific formats vary depending on the domain plug-in.|
4131
4132**Return value**
4133
4134| Type                     | Description                    |
4135| :------------------------ | ----------------------- |
4136| Promise&lt;Uint8Array&gt; | Promise used to return the service access token obtained.|
4137
4138**Error codes**
4139
4140| ID| Error Message                    |
4141| -------- | --------------------------- |
4142| 202 | Not system application.|
4143| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4144| 801 | Capability not supported.|
4145| 12300001 | The system service works abnormally. |
4146| 12300002 | Invalid business parameters. |
4147| 12300003 | Domain account not found. |
4148| 12300013 | Network exception. |
4149| 12300014 | The domain account is not authenticated. |
4150| 12300111 | The authentication time out. |
4151
4152**Example**
4153  ```ts
4154  import { BusinessError } from '@kit.BasicServicesKit';
4155  let businessParams: Record<string, Object> = {
4156    'clientId': 'xxx',
4157    'secretId': 'yyy'
4158  };  // depends on the implementation of the domain plugin
4159  try {
4160    osAccount.DomainAccountManager.getAccessToken(businessParams)
4161      .then((result: Uint8Array) => {
4162      console.log('getAccessToken result: ' + result);
4163    }).catch((err: BusinessError) => {
4164      console.log('getAccessToken failed, error: ' + JSON.stringify(err));
4165    });
4166  } catch (err) {
4167    console.log('getAccessToken exception = ' + JSON.stringify(err));
4168  }
4169  ```
4170
4171### isAuthenticationExpired<sup>12+</sup>
4172
4173isAuthenticationExpired(domainAccountInfo: DomainAccountInfo): Promise&lt;boolean&gt;;
4174
4175Checks whether the authentication of a domain account has expired. This API uses a promise to return the result.
4176
4177**System API**: This is a system API.
4178
4179**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS or ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
4180
4181**System capability**: SystemCapability.Account.OsAccount
4182
4183**Parameters**
4184
4185| Name     | Type                                   | Mandatory| Description            |
4186| ---------- | --------------------------------------- | ---- | --------------- |
4187| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes  | Domain account information.|
4188
4189**Return value**
4190
4191| Type                     | Description                    |
4192| :------------------------ | ----------------------- |
4193| Promise&lt;boolean&gt; | Promise used to return the result.|
4194
4195**Error codes**
4196
4197| ID| Error Message                    |
4198| -------- | --------------------------- |
4199| 201 | Permission denied.|
4200| 202 | Not system application.|
4201| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4202| 801 | Capability not supported.|
4203| 12300001 | The system service works abnormally. |
4204| 12300003 | Domain account not found. |
4205
4206**Example**
4207  ```ts
4208  import { BusinessError } from '@kit.BasicServicesKit';
4209  let domainInfo: osAccount.DomainAccountInfo =
4210    {domain: 'testDomain', accountName: 'testAccountName'};
4211  try {
4212    osAccount.DomainAccountManager.isAuthenticationExpired(domainInfo).then((result: boolean) => {
4213      console.log('isAuthenticationExpired, result: ' + result);
4214    }).catch((err: BusinessError) => {
4215      console.log('isAuthenticationExpired err: ' + err);
4216    });
4217  } catch (e) {
4218    console.log('isAuthenticationExpired exception: ' + e);
4219  }
4220  ```
4221
4222## DomainServerConfig<sup>12+</sup>
4223
4224Represents the configuration of a domain server.
4225
4226**System API**: This is a system API.
4227
4228**System capability**: SystemCapability.Account.OsAccount
4229
4230| Name     | Type  | Mandatory| Description      |
4231| ----------- | ------ | ---- | ---------- |
4232| parameters | Record<string, Object> | Yes  | Server configuration parameters.|
4233| id | string | Yes  | Server configuration ID.|
4234| domain | string | Yes| Domain to which the server belongs.|
4235
4236## DomainServerConfigManager<sup>12+</sup>
4237
4238Provides APIs for domain server configuration and management.
4239
4240### addServerConfig<sup>12+</sup>
4241
4242static addServerConfig(parameters: Record&lt;string, Object&gt;): Promise&lt;DomainServerConfig&gt;
4243
4244Adds domain server configuration. This API uses a promise to return the result.
4245
4246**System API**: This is a system API.
4247
4248**System capability**: SystemCapability.Account.OsAccount
4249
4250**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
4251
4252**Parameters**
4253
4254| Name   | Type                    | Mandatory| Description                     |
4255| ----------| ----------------------- | --- | -------------------------- |
4256| parameters   | Record<string, Object>  | Yes | Configuration parameters of the domain server.|
4257
4258**Return value**
4259
4260| Type                     | Description                    |
4261| :------------------------ | ----------------------- |
4262| Promise&lt;[DomainServerConfig](#domainserverconfig12)&gt; | Promise used to return the configuration of the newly added domain server.|
4263
4264**Error codes**
4265
4266| ID| Error Message                    |
4267| -------- | --------------------------- |
4268| 201 | Permission denied.|
4269| 202 | Not system application.|
4270| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4271| 801 | Capability not supported.|
4272| 12300001 | The system service works abnormally. |
4273| 12300002 | - Invalid server config parameters. |
4274| 12300211 | - Server unreachable. |
4275
4276**Example**
4277  ```ts
4278  import { BusinessError } from '@kit.BasicServicesKit';
4279  let configParams: Record<string, Object> = {
4280    'uri': 'test.example.com',
4281    'port': 100
4282  };
4283  osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
4284    serverConfig: osAccount.DomainServerConfig) => {
4285    console.log('add server configuration successfully, the return config: ' + JSON.stringify(serverConfig));
4286  }).catch((err: BusinessError) => {
4287    console.log('add server configuration failed, error: ' + JSON.stringify(err));
4288  });
4289  ```
4290
4291### removeServerConfig<sup>12+</sup>
4292
4293static removeServerConfig(configId: string): Promise&lt;void&gt;
4294
4295Deletes domain server configuration. This API uses a promise to return the result.
4296
4297**System API**: This is a system API.
4298
4299**System capability**: SystemCapability.Account.OsAccount
4300
4301**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
4302
4303**Parameters**
4304
4305| Name   | Type                    | Mandatory| Description                     |
4306| ----------| ----------------------- | --- | -------------------------- |
4307| configId   | string  | Yes | Server configuration ID.|
4308
4309**Return value**
4310
4311| Type                     | Description                    |
4312| :------------------------ | ----------------------- |
4313| Promise&lt;void&gt; | Promise that returns no value.|
4314
4315**Error codes**
4316
4317| ID| Error Message                    |
4318| -------- | --------------------------- |
4319| 201 | Permission denied.|
4320| 202 | Not system application.|
4321| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4322| 801 | Capability not supported.|
4323| 12300001 | The system service works abnormally. |
4324| 12300212 | - Server config not found. |
4325
4326**Example**
4327  ```ts
4328  import { BusinessError } from '@kit.BasicServicesKit';
4329  let configParams: Record<string, Object> = {
4330    'uri': 'test.example.com',
4331    'port': 100
4332  };
4333  osAccount.DomainServerConfigManager.addServerConfig(configParams).then((
4334    serverConfig: osAccount.DomainServerConfig) => {
4335    console.log('add domain server configuration successfully, the added config: ' + JSON.stringify(serverConfig));
4336    osAccount.DomainServerConfigManager.removeServerConfig(serverConfig.id);
4337    console.log('remove domain server configuration successfully');
4338  }).catch((err: BusinessError) => {
4339    console.log('add server configuration failed, error: ' + JSON.stringify(err));
4340  });
4341  ```
4342
4343### getAccountServerConfig<sup>12+</sup>
4344
4345static getAccountServerConfig(domainAccountInfo: DomainAccountInfo): Promise&lt;DomainServerConfig&gt;
4346
4347Obtains the server configuration of a domain account. This API uses a promise to return the result.
4348
4349**System API**: This is a system API.
4350
4351**System capability**: SystemCapability.Account.OsAccount
4352
4353**Required permissions**: ohos.permission.MANAGE_LOCAL_ACCOUNTS
4354
4355**Parameters**
4356
4357| Name   | Type                    | Mandatory| Description                     |
4358| ----------| ----------------------- | --- | -------------------------- |
4359| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | Yes | Information of the domain account.|
4360
4361**Return value**
4362
4363| Type                     | Description                    |
4364| :------------------------ | ----------------------- |
4365| Promise&lt;[DomainServerConfig](#domainserverconfig12)&gt; | Promise used to return the domain server configuration of the account.|
4366
4367**Error codes**
4368
4369| ID| Error Message                    |
4370| -------- | --------------------------- |
4371| 201 | Permission denied.|
4372| 202 | Not system application.|
4373| 401 |Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4374| 801 | Capability not supported.|
4375| 12300001 | The system service works abnormally. |
4376| 12300003 | Domain account not found. |
4377
4378**Example**
4379  ```ts
4380  import { BusinessError } from '@kit.BasicServicesKit';
4381  let accountInfo: osAccount.DomainAccountInfo = {
4382    'accountName': 'demoName',
4383    'accountId': 'demoId',
4384    'domain': 'demoDomain'
4385  };
4386  osAccount.DomainServerConfigManager.getAccountServerConfig(accountInfo).then((
4387    serverConfig: osAccount.DomainServerConfig) => {
4388    console.log('get account server configuration successfully, the return config: ' + JSON.stringify(serverConfig));
4389  }).catch((err: BusinessError) => {
4390    console.log('add server configuration failed, error: ' + JSON.stringify(err));
4391  });
4392  ```
4393
4394## UserIdentityManager<sup>8+</sup>
4395
4396Provides APIs for user IDM.
4397
4398**System API**: This is a system API.
4399
4400### constructor<sup>8+</sup>
4401
4402constructor()
4403
4404A constructor used to create an instance for user IDM.
4405
4406**System API**: This is a system API.
4407
4408**System capability**: SystemCapability.Account.OsAccount
4409
4410**Error codes**
4411
4412| ID| Error Message                    |
4413| -------- | --------------------------- |
4414| 202 | Not system application.|
4415
4416**Example**
4417  ```ts
4418  let userIDM = new osAccount.UserIdentityManager();
4419  ```
4420
4421### openSession<sup>8+</sup>
4422
4423openSession(callback: AsyncCallback&lt;Uint8Array&gt;): void
4424
4425Opens a session to obtain the challenge value. This API uses an asynchronous callback to return the result.
4426
4427**System API**: This is a system API.
4428
4429**System capability**: SystemCapability.Account.OsAccount
4430
4431**Required permissions**: ohos.permission.MANAGE_USER_IDM
4432
4433**Parameters**
4434
4435| Name   | Type                            | Mandatory| Description                                                           |
4436| -------- | -------------------------------- | ---- | -------------------------------------------------------------- |
4437| callback | AsyncCallback&lt;Uint8Array&gt;  | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the challenge value obtained. Otherwise, **err** is an error object.|
4438
4439**Error codes**
4440
4441| ID| Error Message                    |
4442| -------- | --------------------------- |
4443| 201 | Permission denied.|
4444| 202 | Not system application.|
4445| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4446| 12300001 | The system service works abnormally. |
4447
4448**Example**
4449  ```ts
4450  import { BusinessError } from '@kit.BasicServicesKit';
4451  let userIDM = new osAccount.UserIdentityManager();
4452  try {
4453    userIDM.openSession((err: BusinessError, challenge: Uint8Array) => {
4454        console.log('openSession error = ' + JSON.stringify(err));
4455        console.log('openSession challenge = ' + JSON.stringify(challenge));
4456    });
4457  } catch (e) {
4458    console.log('openSession exception = ' + JSON.stringify(e));
4459  }
4460  ```
4461
4462### openSession<sup>8+</sup>
4463
4464openSession(accountId?: number): Promise&lt;Uint8Array&gt;
4465
4466Opens a session. This API returns a challenge value, which can be used to determine whether the subsequent identity authentication is in this session. This can prevent replay attacks. This API uses a promise to return the result.
4467
4468**System API**: This is a system API.
4469
4470**System capability**: SystemCapability.Account.OsAccount
4471
4472**Required permissions**: ohos.permission.MANAGE_USER_IDM
4473
4474**Parameters**
4475
4476| Name    | Type   | Mandatory| Description       |
4477| --------- | ------- | ---- | ----------- |
4478| accountId<sup>12+</sup> | number  | No  | System account ID, which is left blank by default.|
4479
4480**Return value**
4481
4482| Type                     | Description                    |
4483| :------------------------ | ----------------------- |
4484| Promise&lt;Uint8Array&gt; | Promise used to return the challenge value obtained.|
4485
4486**Error codes**
4487
4488| ID| Error Message                    |
4489| -------- | --------------------------- |
4490| 201 | Permission denied.|
4491| 202 | Not system application.|
4492| 401 | Parameter error. Possible causes: Incorrect parameter types. |
4493| 12300001 | The system service works abnormally. |
4494| 12300003 | Account not found. |
4495| 12300008 | Restricted account. |
4496
4497**Example**
4498  ```ts
4499  import { BusinessError } from '@kit.BasicServicesKit';
4500  let userIDM = new osAccount.UserIdentityManager();
4501  let accountId = 100;
4502  try {
4503    userIDM.openSession(accountId).then((challenge: Uint8Array) => {
4504        console.info('openSession challenge = ' + JSON.stringify(challenge));
4505    }).catch((err: BusinessError) => {
4506        console.info('openSession error = ' + JSON.stringify(err));
4507    });
4508  } catch (e) {
4509    console.log('openSession exception = ' + JSON.stringify(e));
4510  }
4511  ```
4512
4513### addCredential<sup>8+</sup>
4514
4515addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void
4516
4517Adds credential information, including the credential type, subtype, and token (if a non-PIN credential is added).
4518
4519**System API**: This is a system API.
4520
4521**System capability**: SystemCapability.Account.OsAccount
4522
4523**Required permissions**: ohos.permission.MANAGE_USER_IDM
4524
4525**Parameters**
4526
4527| Name          | Type                                | Mandatory| Description                       |
4528| --------------- | ------------------------------------ | --- | ---------------------------- |
4529| credentialInfo  | [CredentialInfo](#credentialinfo8)   | Yes | Credential information to add.               |
4530| callback        | [IIdmCallback](#iidmcallback8)       | Yes | Callback used to return the result. |
4531
4532**Error codes**
4533
4534| ID| Error Message                    |
4535| -------- | ------------------- |
4536| 201 | Permission denied.|
4537| 202 | Not system application.|
4538| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4539| 12300001 | The system service works abnormally. |
4540| 12300002 | Invalid credentialInfo, i.e. authType or authSubType. |
4541| 12300003 | Account not found. |
4542| 12300008 | Restricted account. |
4543| 12300101 | The token is invalid. |
4544| 12300106 | The authentication type is not supported. |
4545| 12300109 | The authentication, enrollment, or update operation is canceled. |
4546| 12300111 | The authentication time out. |
4547| 12300115 | The number of credentials reaches the upper limit. |
4548| 12300116 | Credential complexity verification failed. |
4549
4550**Example**
4551  ```ts
4552  import { BusinessError } from '@kit.BasicServicesKit';
4553  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
4554  let pinAuth: osAccount.PINAuth = new osAccount.PINAuth();
4555  pinAuth.registerInputer({
4556    onGetData: (authSubType: osAccount.AuthSubType, callback: osAccount.IInputData) => {
4557      callback.onSetData(authSubType, password);
4558    }
4559  });
4560  let credentialInfo: osAccount.CredentialInfo = {
4561    credType: osAccount.AuthType.PIN,
4562    credSubType: osAccount.AuthSubType.PIN_SIX,
4563    token: new Uint8Array([]),
4564  };
4565  let userIDM = new osAccount.UserIdentityManager();
4566  userIDM.openSession((err: BusinessError, challenge: Uint8Array) => {
4567    try {
4568    userIDM.addCredential(credentialInfo, {
4569      onResult: (result: number, extraInfo: osAccount.RequestResult) => {
4570        console.log('addCredential result = ' + result);
4571        console.log('addCredential extraInfo = ' + extraInfo);
4572      }
4573    });
4574    } catch (e) {
4575      console.log('addCredential exception = ' + JSON.stringify(e));
4576    }
4577  });
4578  ```
4579
4580### updateCredential<sup>8+</sup>
4581
4582updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void
4583
4584Updates credential information. This API uses an asynchronous callback to return the result.
4585
4586**System API**: This is a system API.
4587
4588**System capability**: SystemCapability.Account.OsAccount
4589
4590**Required permissions**: ohos.permission.MANAGE_USER_IDM
4591
4592**Parameters**
4593
4594| Name          | Type                                 | Mandatory| Description                    |
4595| --------------- | ------------------------------------- | --- | ------------------------- |
4596| credentialInfo  | [CredentialInfo](#credentialinfo8)    | Yes | Credential information to add.            |
4597| callback        | [IIdmCallback](#iidmcallback8)        | Yes | Callback used to return the result.|
4598
4599**Error codes**
4600
4601| ID| Error Message                    |
4602| -------- | ------------------- |
4603| 201 | Permission denied.|
4604| 202 | Not system application.|
4605| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4606| 12300001 | The system service works abnormally. |
4607| 12300002 | Invalid credentialInfo, i.e. authType or authSubType or token. |
4608| 12300003 | Account not found. |
4609| 12300101 | The token is invalid. |
4610| 12300102 | Credential not enrolled.|
4611| 12300106 | The authentication type is not supported. |
4612| 12300109 | The authentication, enrollment, or update operation is canceled. |
4613| 12300111 | The authentication time out. |
4614| 12300116 | Credential complexity verification failed. |
4615
4616**Example**
4617  ```ts
4618  import { BusinessError } from '@kit.BasicServicesKit';
4619  let userIDM = new osAccount.UserIdentityManager();
4620  let userAuth: osAccount.UserAuth = new osAccount.UserAuth();
4621  let pinAuth: osAccount.PINAuth = new osAccount.PINAuth();
4622  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
4623  let credentialInfo: osAccount.CredentialInfo = {
4624    credType: osAccount.AuthType.PIN,
4625    credSubType: osAccount.AuthSubType.PIN_SIX,
4626    token: new Uint8Array([]),
4627  };
4628  pinAuth.registerInputer({
4629    onGetData: (authSubType: osAccount.AuthSubType, callback: osAccount.IInputData) => {
4630      callback.onSetData(authSubType, password);
4631    }
4632  });
4633  userIDM.openSession((err: BusinessError, challenge: Uint8Array) => {
4634    userAuth.auth(challenge, credentialInfo.credType, osAccount.AuthTrustLevel.ATL1, {
4635      onResult: (result: number, extraInfo: osAccount.AuthResult) => {
4636        if (result != osAccount.ResultCode.SUCCESS) {
4637          return;
4638        }
4639        if (extraInfo.token != null) {
4640          credentialInfo.token = extraInfo.token;
4641        }
4642        try {
4643          userIDM.updateCredential(credentialInfo, {
4644            onResult: (result: number, extraInfo: osAccount.RequestResult) => {
4645                console.log('updateCredential result = ' + result);
4646                console.log('updateCredential extraInfo = ' + extraInfo);
4647            }
4648          });
4649        } catch (e) {
4650          console.log('updateCredential exception = ' + JSON.stringify(e));
4651        }
4652      }
4653    });
4654  });
4655  ```
4656
4657### closeSession<sup>8+</sup>
4658
4659closeSession(accountId?: number): void
4660
4661Closes this session to terminate IDM.
4662
4663**System API**: This is a system API.
4664
4665**System capability**: SystemCapability.Account.OsAccount
4666
4667**Required permissions**: ohos.permission.MANAGE_USER_IDM
4668
4669**Parameters**
4670
4671| Name    | Type   | Mandatory| Description       |
4672| --------- | ------- | ---- | ----------- |
4673| accountId<sup>12+</sup> | number  | No  | System account ID, which is left blank by default.|
4674
4675**Error codes**
4676
4677| ID| Error Message                    |
4678| -------- | --------------------------- |
4679| 201 | Permission denied.|
4680| 202 | Not system application.|
4681| 401 | Parameter error. Possible causes: Incorrect parameter types. |
4682| 12300001 | The system service works abnormally. |
4683| 12300003 | Account not found. |
4684| 12300008 | Restricted account. |
4685
4686**Example**
4687  ```ts
4688  let userIDM = new osAccount.UserIdentityManager();
4689  let accountId = 100;
4690  userIDM.closeSession(accountId);
4691  ```
4692
4693### cancel<sup>8+</sup>
4694
4695cancel(challenge: Uint8Array): void
4696
4697Cancels an entry based on the challenge value.
4698
4699**System API**: This is a system API.
4700
4701**System capability**: SystemCapability.Account.OsAccount
4702
4703**Required permissions**: ohos.permission.MANAGE_USER_IDM
4704
4705**Parameters**
4706
4707| Name   | Type       | Mandatory| Description  |
4708| -------- | ----------- | ---- | ----- |
4709| challenge | Uint8Array | Yes  | Challenge value.|
4710
4711**Error codes**
4712
4713| ID| Error Message           |
4714| -------- | ------------------- |
4715| 201 | Permission denied.|
4716| 202 | Not system application.|
4717| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4718| 12300001 | The system service works abnormally. |
4719| 12300002 | Invalid challenge. |
4720
4721**Example**
4722  ```ts
4723  let userIDM = new osAccount.UserIdentityManager();
4724  let challenge: Uint8Array = new Uint8Array([0]);
4725  try {
4726    userIDM.cancel(challenge);
4727  } catch(err) {
4728    console.log('cancel err:' + JSON.stringify(err));
4729  }
4730  ```
4731
4732### delUser<sup>8+</sup>
4733
4734delUser(token: Uint8Array, callback: IIdmCallback): void
4735
4736Deletes a user based on the authentication token. This API uses a callback to return the result.
4737
4738**System API**: This is a system API.
4739
4740**System capability**: SystemCapability.Account.OsAccount
4741
4742**Required permissions**: ohos.permission.MANAGE_USER_IDM
4743
4744**Parameters**
4745
4746| Name   | Type                          | Mandatory| Description                     |
4747| -------- | ------------------------------ | --- | ------------------------- |
4748| token    | Uint8Array                     | Yes | Authentication token.            |
4749| callback | [IIdmCallback](#iidmcallback8) | Yes | Callback used to return the result.|
4750
4751**Error codes**
4752
4753| ID| Error Message       |
4754| -------- | ------------------- |
4755| 201 | Permission denied.|
4756| 202 | Not system application.|
4757| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4758| 12300001 | The system service works abnormally. |
4759| 12300101 | The token is invalid. |
4760
4761**Example**
4762  ```ts
4763  let userIDM = new osAccount.UserIdentityManager();
4764  let token: Uint8Array = new Uint8Array([0]);
4765  try {
4766    userIDM.delUser(token, {
4767      onResult: (result: number, extraInfo: osAccount.RequestResult) => {
4768        console.log('delUser result = ' + result);
4769        console.log('delUser extraInfo = ' + JSON.stringify(extraInfo));
4770      }
4771    });
4772  } catch (e) {
4773    console.log('delUser exception = ' + JSON.stringify(e));
4774  }
4775  ```
4776
4777### delCred<sup>8+</sup>
4778
4779delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): void
4780
4781Deletes user credential information.
4782
4783**System API**: This is a system API.
4784
4785**System capability**: SystemCapability.Account.OsAccount
4786
4787**Required permissions**: ohos.permission.MANAGE_USER_IDM
4788
4789**Parameters**
4790
4791| Name          | Type                                           | Mandatory| Description                     |
4792| --------------- | ----------------------------------- | --- | ---------------------------|
4793| credentialId    | Uint8Array                          | Yes | Credential ID.                 |
4794| token           | Uint8Array                          | Yes | Authentication token.              |
4795| callback        | [IIdmCallback](#iidmcallback8)      | Yes | Callback used to return the result.|
4796
4797**Error codes**
4798
4799| ID| Error Message            |
4800| -------- | ------------------- |
4801| 201 | Permission denied.|
4802| 202 | Not system application.|
4803| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4804| 12300001 | The system service works abnormally. |
4805| 12300002 | Invalid credentialId. |
4806| 12300101 | The token is invalid. |
4807| 12300102 | Credential not enrolled. |
4808
4809**Example**
4810  ```ts
4811  let userIDM = new osAccount.UserIdentityManager();
4812  let credentialId: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]);
4813  let token: Uint8Array = new Uint8Array([0]);
4814  try {
4815    userIDM.delCred(credentialId, token, {
4816      onResult: (result: number, extraInfo: osAccount.RequestResult) => {
4817          console.log('delCred result = ' + result);
4818          console.log('delCred extraInfo = ' + JSON.stringify(extraInfo));
4819      }
4820    });
4821  } catch (e) {
4822    console.log('delCred exception = ' + JSON.stringify(e));
4823  }
4824  ```
4825
4826### getAuthInfo<sup>8+</sup>
4827
4828getAuthInfo(callback: AsyncCallback&lt;Array&lt;EnrolledCredInfo&gt;&gt;): void
4829
4830Obtains authentication information. This API uses an asynchronous callback to return the result.
4831
4832**System API**: This is a system API.
4833
4834**System capability**: SystemCapability.Account.OsAccount
4835
4836**Required permissions**: ohos.permission.USE_USER_IDM
4837
4838**Parameters**
4839
4840| Name   | Type                                                                    | Mandatory| Description                                                |
4841| -------- | ------------------------------------------------------------------------ | ---- | --------------------------------------------- |
4842| callback | AsyncCallback&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is information about all registered credentials of the user. Otherwise, **err** is an error object.|
4843
4844**Error codes**
4845
4846| ID| Error Message              |
4847| -------- | --------------------- |
4848| 201 | Permission denied.|
4849| 202 | Not system application.|
4850| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4851| 12300001 | The system service works abnormally. |
4852| 12300102 | Credential not enrolled. |
4853
4854**Example**
4855  ```ts
4856  import { BusinessError } from '@kit.BasicServicesKit';
4857  let userIDM = new osAccount.UserIdentityManager();
4858  try {
4859    userIDM.getAuthInfo((err: BusinessError, result: osAccount.EnrolledCredInfo[]) => {
4860      console.log('getAuthInfo err = ' + JSON.stringify(err));
4861      console.log('getAuthInfo result = ' + JSON.stringify(result));
4862    });
4863  } catch (e) {
4864    console.log('getAuthInfo exception = ' + JSON.stringify(e));
4865  }
4866  ```
4867
4868### getAuthInfo<sup>8+</sup>
4869
4870getAuthInfo(authType: AuthType, callback: AsyncCallback&lt;Array&lt;EnrolledCredInfo&gt;&gt;): void
4871
4872Obtains authentication information of the specified type. This API uses an asynchronous callback to return the result.
4873
4874**System API**: This is a system API.
4875
4876**System capability**: SystemCapability.Account.OsAccount
4877
4878**Required permissions**: ohos.permission.USE_USER_IDM
4879
4880**Parameters**
4881
4882| Name   | Type                                              | Mandatory| Description                                               |
4883| -------- | -------------------------------------------------- | ---- | -------------------------------------------------- |
4884| authType | [AuthType](#authtype8) | Yes  | Authentication credential type.                                         |
4885| callback | AsyncCallback&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Yes  | Callback used to return the result. If the operation is successful, **err** is **null** and **data** is the information about all enrolled credentials of the specified type. Otherwise, **err** is an error object.|
4886
4887**Error codes**
4888
4889| ID| Error Message              |
4890| -------- | ------------------- |
4891| 201 | Permission denied.|
4892| 202 | Not system application.|
4893| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
4894| 12300001 | The system service works abnormally. |
4895| 12300002 | Invalid authType. |
4896| 12300102 | Credential not enrolled. |
4897
4898**Example**
4899  ```ts
4900  import { BusinessError } from '@kit.BasicServicesKit';
4901  let userIDM = new osAccount.UserIdentityManager();
4902  try {
4903    userIDM.getAuthInfo(osAccount.AuthType.PIN,
4904      (err: BusinessError, result: osAccount.EnrolledCredInfo[]) => {
4905      console.log('getAuthInfo err = ' + JSON.stringify(err));
4906      console.log('getAuthInfo result = ' + JSON.stringify(result));
4907    });
4908  } catch (e) {
4909    console.log('getAuthInfo exception = ' + JSON.stringify(e));
4910  }
4911  ```
4912
4913### getAuthInfo<sup>8+</sup>
4914
4915getAuthInfo(authType?: AuthType): Promise&lt;Array&lt;EnrolledCredInfo&gt;&gt;;
4916
4917Obtains authentication information of the specified type. This API uses a promise to return the result.
4918
4919**System API**: This is a system API.
4920
4921**System capability**: SystemCapability.Account.OsAccount
4922
4923**Required permissions**: ohos.permission.USE_USER_IDM
4924
4925**Parameters**
4926
4927| Name   | Type                               | Mandatory| Description     |
4928| -------- | ----------------------------------- | ---- | -------- |
4929| authType | [AuthType](#authtype8)              | No  | Authentication type. By default, this parameter is left blank, which means to obtain information about all authentication types.|
4930
4931**Return value**
4932
4933| Type                                        | Description                                                                    |
4934| :------------------------------------------- | :----------------------------------------------------------------------- |
4935| Promise&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Promise used to return the information about all the enrolled credentials of the specified type.|
4936
4937**Error codes**
4938
4939| ID| Error Message              |
4940| -------- | ------------------- |
4941| 201 | Permission denied.|
4942| 202 | Not system application.|
4943| 401 | Parameter error. Possible causes: Incorrect parameter types. |
4944| 12300001 | The system service works abnormally. |
4945| 12300002 | Invalid authType. |
4946| 12300102 | Credential not enrolled. |
4947
4948**Example**
4949  ```ts
4950  import { BusinessError } from '@kit.BasicServicesKit';
4951  let userIDM = new osAccount.UserIdentityManager();
4952  try {
4953    userIDM.getAuthInfo(osAccount.AuthType.PIN).then((result: osAccount.EnrolledCredInfo[]) => {
4954      console.log('getAuthInfo result = ' + JSON.stringify(result))
4955    }).catch((err: BusinessError) => {
4956      console.log('getAuthInfo error = ' + JSON.stringify(err));
4957    });
4958  } catch (e) {
4959    console.log('getAuthInfo exception = ' + JSON.stringify(e));
4960  }
4961  ```
4962
4963### getAuthInfo<sup>12+</sup>
4964
4965getAuthInfo(options?: GetAuthInfoOptions): Promise&lt;Array&lt;EnrolledCredInfo&gt;&gt;
4966
4967Obtains authentication information. This API uses a promise to return the result.
4968
4969**System API**: This is a system API.
4970
4971**System capability**: SystemCapability.Account.OsAccount
4972
4973**Required permissions**: ohos.permission.USE_USER_IDM
4974
4975**Parameters**
4976
4977| Name   | Type                               | Mandatory| Description     |
4978| -------- | ----------------------------------- | ---- | -------- |
4979| options | [GetAuthInfoOptions](#getauthinfooptions12)          | No  | Optional parameters for obtaining authentication information.|
4980
4981**Return value**
4982
4983| Type                                        | Description                                                                    |
4984| :------------------------------------------- | :----------------------------------------------------------------------- |
4985| Promise&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Promise used to return the information about all the enrolled credentials of the specified type.|
4986
4987**Error codes**
4988
4989| ID| Error Message              |
4990| -------- | ------------------- |
4991| 201 | Permission denied.|
4992| 202 | Not system application.|
4993| 401 | Parameter error. Possible causes: Incorrect parameter types. |
4994| 12300001 | The system service works abnormally. |
4995| 12300002 | Invalid options. |
4996| 12300003 | Account not found. |
4997
4998**Example**
4999  ```ts
5000  import { BusinessError } from '@kit.BasicServicesKit';
5001  let userIDM = new osAccount.UserIdentityManager();
5002  let options: osAccount.GetAuthInfoOptions = {
5003    authType: osAccount.AuthType.PIN,
5004    accountId: 100,
5005  };
5006  try {
5007    userIDM.getAuthInfo(options).then((result: osAccount.EnrolledCredInfo[]) => {
5008      console.log('getAuthInfo result = ' + JSON.stringify(result))
5009    }).catch((err: BusinessError) => {
5010      console.log('getAuthInfo error = ' + JSON.stringify(err));
5011    });
5012  } catch (e) {
5013    console.log('getAuthInfo exception = ' + JSON.stringify(e));
5014  }
5015  ```
5016
5017### getEnrolledId<sup>12+</sup>
5018
5019getEnrolledId(authType: AuthType, accountId?: number): Promise&lt;Uint8Array&gt;
5020
5021Obtains the ID of the enrolled credential based on the credential type and account ID (optional). This API uses a promise to return the result.
5022
5023**System API**: This is a system API.
5024
5025**System capability**: SystemCapability.Account.OsAccount
5026
5027**Required permissions**: ohos.permission.USE_USER_IDM
5028
5029**Parameters**
5030
5031| Name    | Type                  | Mandatory| Description     |
5032| --------  | ---------------------- | ---- | -------- |
5033| authType  | [AuthType](#authtype8) | Yes  | Credential type.|
5034| accountId | number                 | No  | System account ID, which is left blank by default.|
5035
5036**Return value**
5037
5038| Type                      | Description                                                                    |
5039| :------------------------ | :----------------------------------------------------------------------- |
5040| Promise&lt;Uint8Array&gt; | Promise used to return the credential ID obtained.|
5041
5042**Error codes**
5043
5044| ID| Error Message              |
5045| -------- | ------------------- |
5046| 201 | Permission denied.|
5047| 202 | Not system application.|
5048| 401      | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types. |
5049| 12300001 | The system service works abnormally. |
5050| 12300002 | Invalid authType. |
5051| 12300003 | Account not found. |
5052| 12300102 | Credential not enrolled. |
5053| 12300106 | The authentication type is not supported. |
5054
5055**Example**
5056  ```ts
5057  import { BusinessError } from '@kit.BasicServicesKit';
5058  let userIDM = new osAccount.UserIdentityManager();
5059  let authType: osAccount.AuthType = osAccount.AuthType.PIN;
5060  let accountId = 100;
5061  try {
5062    userIDM.getEnrolledId(authType, accountId).then((enrolledId: Uint8Array) => {
5063        console.info('getEnrolledId enrolledId = ' + JSON.stringify(enrolledId));
5064    }).catch((err: BusinessError) => {
5065        console.info('getEnrolledId error = ' + JSON.stringify(err));
5066    });
5067  } catch (e) {
5068    console.log('getEnrolledId exception = ' + JSON.stringify(e));
5069  }
5070  ```
5071
5072## IInputData<sup>8+</sup>
5073
5074Provides callbacks for PIN operations.
5075
5076**System API**: This is a system API.
5077
5078### onSetData<sup>8+</sup>
5079
5080onSetData: (authSubType: AuthSubType, data: Uint8Array) => void;
5081
5082**System API**: This is a system API.
5083
5084Called to notify the caller the data is set.
5085
5086**System capability**: SystemCapability.Account.OsAccount
5087
5088**Parameters**
5089
5090| Name     | Type                                    | Mandatory| Description                                           |
5091| ---------- | ---------------------------------------- | ---- | ----------------------------------------------- |
5092| authSubType | [AuthSubType](#authsubtype8)             | Yes  | Credential subtype.                           |
5093| data       | Uint8Array                               | Yes  | Data (credential) to set. The data is used for authentication and operations for adding and modifying credentials.|
5094
5095**Error codes**
5096
5097| ID| Error Message              |
5098| -------- | ------------------- |
5099| 202 | Not system application.|
5100| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified. 2. Incorrect parameter types. |
5101| 12300002 | Invalid pinSubType. |
5102
5103**Example**
5104  ```ts
5105  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
5106  let passwordNumber: Uint8Array = new Uint8Array([1, 2, 3, 4]);
5107  let inputer: osAccount.IInputer = {
5108    onGetData: (authSubType: osAccount.AuthSubType, callback: osAccount.IInputData) => {
5109        if (authSubType == osAccount.AuthSubType.PIN_NUMBER) {
5110          callback.onSetData(authSubType, passwordNumber);
5111        } else {
5112          callback.onSetData(authSubType, password);
5113        }
5114    }
5115  };
5116  ```
5117
5118## IInputer<sup>8+</sup>
5119
5120Provides callbacks for credential inputers.
5121
5122**System API**: This is a system API.
5123
5124### onGetData<sup>8+</sup>
5125
5126onGetData: (authSubType: AuthSubType, callback: IInputData, options: GetInputDataOptions) => void;
5127
5128Called to notify the caller that data is obtained.
5129
5130**System API**: This is a system API.
5131
5132**System capability**: SystemCapability.Account.OsAccount
5133
5134**Parameters**
5135
5136| Name     | Type                                   | Mandatory| Description            |
5137| ---------- | --------------------------------------- | ---- | --------------- |
5138| authSubType | [AuthSubType](#authsubtype8) | Yes| Authentication credential subtype.|
5139| callback   | [IInputData](#iinputdata8)  | Yes  | Callback used to return the PIN data.|
5140| options | [GetInputDataOptions](#getinputdataoptions-12) | Yes| Optional parameters for the callback function.|
5141
5142**Example**
5143  ```ts
5144  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
5145  let passwordNumber: Uint8Array = new Uint8Array([1, 2, 3, 4]);
5146  let inputer: osAccount.IInputer = {
5147    onGetData: (authSubType: osAccount.AuthSubType,
5148      callback: osAccount.IInputData, options: osAccount.GetInputDataOptions) => {
5149        if (authSubType == osAccount.AuthSubType.PIN_NUMBER) {
5150          callback.onSetData(authSubType, passwordNumber);
5151        } else {
5152          callback.onSetData(authSubType, password);
5153        }
5154    }
5155  };
5156  let pinAuth: osAccount.PINAuth = new osAccount.PINAuth();
5157  let result = pinAuth.registerInputer(inputer);
5158  console.log('registerInputer result: ' + result);
5159  ```
5160
5161## IUserAuthCallback<sup>8+</sup>
5162
5163Provides callbacks for user authentication.
5164
5165**System API**: This is a system API.
5166
5167### onResult<sup>8+</sup>
5168
5169onResult: (result: number, extraInfo: AuthResult) => void;
5170
5171Called to return the result code and authentication result.
5172
5173**System API**: This is a system API.
5174
5175**System capability**: SystemCapability.Account.OsAccount
5176
5177**Parameters**
5178
5179| Name    | Type                                   | Mandatory| Description                |
5180| --------- | --------------------------------------- | ---- | ------------------- |
5181| result    | number                                   | Yes  | Authentication result code.|
5182| extraInfo | [AuthResult](#authresult8)  | Yes  | Specific authentication result information. If the authentication is successful, the authentication token is returned in **extrainfo**. If the authentication fails, the remaining authentication time is returned. If the authentication executor is locked, the freezing time is returned.|
5183
5184**Example**
5185  ```ts
5186  let authCallback: osAccount.IUserAuthCallback = {
5187    onResult: (result: number, extraInfo: osAccount.AuthResult) => {
5188      console.log('auth result = ' + result);
5189      console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
5190    }
5191  };
5192  ```
5193
5194### onAcquireInfo?<sup>8+</sup>
5195
5196onAcquireInfo?: (module: number, acquire: number, extraInfo: Uint8Array) => void;
5197
5198Called to acquire identity authentication information.
5199
5200**System API**: This is a system API.
5201
5202**System capability**: SystemCapability.Account.OsAccount
5203
5204**Parameters**
5205
5206| Name   | Type    | Mandatory| Description                          |
5207| --------- | ------- | ---- | ----------------------------- |
5208| module    | number  | Yes  | Type of authentication executor.  |
5209| acquire   | number  | Yes  | Tip code of the authentication executor.|
5210| extraInfo | Uint8Array     | Yes  | Reserved.                    |
5211
5212**Example**
5213  ```ts
5214  let authCallback: osAccount.IUserAuthCallback = {
5215    onResult: (result: number, extraInfo: osAccount.AuthResult) => {
5216      console.log('auth result = ' + result)
5217      console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
5218    },
5219    onAcquireInfo: (module: number, acquire: number, extraInfo: Uint8Array) => {
5220      console.log('auth module = ' + module);
5221      console.log('auth acquire = ' + acquire);
5222      console.info('auth extraInfo = ' + JSON.stringify(extraInfo));
5223    }
5224  };
5225  ```
5226
5227## IIdmCallback<sup>8+</sup>
5228
5229Provides callbacks for IDM.
5230
5231**System API**: This is a system API.
5232
5233### onResult<sup>8+</sup>
5234
5235onResult: (result: number, extraInfo: RequestResult) => void;
5236
5237Called to return the result code and request result information.
5238
5239**System API**: This is a system API.
5240
5241**System capability**: SystemCapability.Account.OsAccount
5242
5243**Parameters**
5244
5245| Name    | Type                                   | Mandatory| Description                    |
5246| --------- | --------------------------------------- | ---- | ----------------------- |
5247| result    | number                                  | Yes  | Authentication result code.   |
5248| extraInfo | [RequestResult](#requestresult8)  | Yes  | Specific information to be transferred.|
5249
5250**Example**
5251  ```ts
5252  let idmCallback: osAccount.IIdmCallback = {
5253    onResult: (result: number, extraInfo: osAccount.RequestResult) => {
5254      console.log('callback result = ' + result)
5255      console.info('callback extraInfo = ' + JSON.stringify(extraInfo));
5256    }
5257  };
5258  ```
5259
5260### onAcquireInfo?<sup>8+</sup>
5261
5262onAcquireInfo?: (module: number, acquire: number, extraInfo: Uint8Array) => void;
5263
5264Called to acquire IDM information.
5265
5266**System API**: This is a system API.
5267
5268**System capability**: SystemCapability.Account.OsAccount
5269
5270**Parameters**
5271
5272| Name   | Type    | Mandatory| Description                          |
5273| --------- | ------- | ---- | ----------------------------- |
5274| module    | number  | Yes  | Type of authentication executor.  |
5275| acquire   | number  | Yes  | Tip code of the authentication executor.|
5276| extraInfo | Uint8Array | Yes  | Reserved.                    |
5277
5278**Example**
5279  ```ts
5280  let idmCallback: osAccount.IIdmCallback = {
5281    onResult: (result: number, extraInfo: Object) => {
5282      console.log('callback result = ' + result)
5283      console.log('callback onResult = ' + JSON.stringify(extraInfo));
5284    },
5285    onAcquireInfo: (module: number, acquire: number, extraInfo: Uint8Array) => {
5286      console.log('callback module = ' + module);
5287      console.log('callback acquire = ' + acquire);
5288      console.log('callback onacquireinfo = ' + JSON.stringify(extraInfo));
5289    }
5290  };
5291  ```
5292
5293## GetPropertyRequest<sup>8+</sup>
5294
5295Defines the request for obtaining property information.
5296
5297**System API**: This is a system API.
5298
5299**System capability**: SystemCapability.Account.OsAccount
5300
5301| Name   | Type                                                         | Mandatory  | Description                  |
5302| -------- | ------------------------------------------------------------- | ----- | ----------------------- |
5303| authType | [AuthType](#authtype8)                            | Yes   | Authentication credential type.       |
5304| keys     | Array&lt;[GetPropertyType](#getpropertytype8)&gt; | Yes   | An array of the types of the properties to obtain.|
5305| accountId<sup>12+</sup> | number | No| System account ID, which is **undefined** by default.|
5306
5307## SetPropertyRequest<sup>8+</sup>
5308
5309Defines the request for setting property information.
5310
5311**System API**: This is a system API.
5312
5313**System capability**: SystemCapability.Account.OsAccount
5314
5315| Name   | Type                                            | Mandatory  | Description                |
5316| -------- | ------------------------------------------------ | ----- | -------------------- |
5317| authType | [AuthType](#authtype8)               | Yes   | Authentication credential type.    |
5318| key     | [SetPropertyType](#setpropertytype8) | Yes   | Type of the property to set.|
5319| setInfo  | Uint8Array                                       | Yes   | Information to set.    |
5320
5321## ExecutorProperty<sup>8+</sup>
5322
5323Defines the executor property.
5324
5325**System API**: This is a system API.
5326
5327**System capability**: SystemCapability.Account.OsAccount
5328
5329| Name        | Type                        |  Readable| Writable| Description             |
5330| ------------ | ---------------------------- | ----- | -----|----------------- |
5331| result       | number                       | Yes   | Yes  | Result.        |
5332| authSubType  | [AuthSubType](#authsubtype8) | Yes   | Yes  | Authentication credential subtype.|
5333| remainTimes  | number                       | Yes   | Yes  | Number of remaining authentication times.    |
5334| freezingTime | number                       | Yes   | Yes  | Freezing time.    |
5335| enrollmentProgress<sup>10+</sup> | string   | Yes   | Yes  | Enrollment progress. By default, no value is passed in.|
5336| sensorInfo<sup>10+</sup> | string           | Yes   | Yes  | Sensor information. By default, no value is passed in.|
5337| nextPhaseFreezingTime<sup>12+</sup> | number | Yes   | Yes  | Next freezing time, which is **undefined** by default.|
5338
5339## AuthResult<sup>8+</sup>
5340
5341Defines the authentication result information.
5342
5343**System API**: This is a system API.
5344
5345**System capability**: SystemCapability.Account.OsAccount
5346
5347| Name       | Type       | Mandatory  | Description             |
5348| ------------ | ----------- | ----- | ----------------- |
5349| token        | Uint8Array  | No   | Authentication token. By default, no value is passed in.     |
5350| remainTimes  | number      | No   | Number of remaining authentication times. By default, no value is passed in.     |
5351| freezingTime | number      | No   | Freezing time. By default, no value is passed in.     |
5352| nextPhaseFreezingTime<sup>12+</sup> | number | No   | Next freezing time, which is **undefined** by default.|
5353| credentialId<sup>12+</sup> | Uint8Array  | No   | Credential ID, which is left blank by default.|
5354| accountId<sup>12+</sup>         | number | No   | System account ID, which is **undefined** by default.|
5355| pinValidityPeriod<sup>12+</sup> | number | No   | Authentication validity period, which is **undefined** by default.|
5356
5357## CredentialInfo<sup>8+</sup>
5358
5359Defines the credential information.
5360
5361**System API**: This is a system API.
5362
5363**System capability**: SystemCapability.Account.OsAccount
5364
5365| Name       | Type                                    | Mandatory  | Description             |
5366| ------------ | ---------------------------------------- | ----- | ----------------- |
5367| credType     | [AuthType](#authtype8)       | Yes   | Authentication credential type.    |
5368| credSubType  | [AuthSubType](#authsubtype8) | Yes   | Authentication credential subtype.  |
5369| token        | Uint8Array                           | Yes   | Authentication token.    |
5370| accountId<sup>12+</sup>    | number | No   | System account ID, which is **undefined** by default.|
5371
5372## RequestResult<sup>8+</sup>
5373
5374Defines the request result information.
5375
5376**System API**: This is a system API.
5377
5378**System capability**: SystemCapability.Account.OsAccount
5379
5380| Name       | Type       | Mandatory  | Description             |
5381| ------------ | ----------- | ----- | ----------------- |
5382| credentialId | Uint8Array  | No   | Credential ID. By default, no value is passed in.     |
5383
5384## EnrolledCredInfo<sup>8+</sup>
5385
5386Defines enrolled credential information.
5387
5388**System API**: This is a system API.
5389
5390**System capability**: SystemCapability.Account.OsAccount
5391
5392| Name       | Type                                    | Mandatory  | Description             |
5393| ------------ | ---------------------------------------- | ----- | ------------------- |
5394| credentialId | Uint8Array                               | Yes   | Credential ID.      |
5395| authType     | [AuthType](#authtype8)       | Yes   | Authentication credential type.  |
5396| authSubType  | [AuthSubType](#authsubtype8) | Yes   | Credential subtype.|
5397| templateId   | Uint8Array                               | Yes   | Authentication credential template ID.    |
5398
5399## GetPropertyType<sup>8+</sup>
5400
5401Enumerates the types of properties to obtain.
5402
5403**System API**: This is a system API.
5404
5405**System capability**: SystemCapability.Account.OsAccount
5406
5407| Name          | Value| Description     |
5408| ------------- | ------ | --------- |
5409| AUTH_SUB_TYPE | 1      | Authentication credential subtype.|
5410| REMAIN_TIMES  | 2      | Number of remaining times.  |
5411| FREEZING_TIME | 3      | Freezing time.  |
5412| ENROLLMENT_PROGRESS<sup>10+</sup> | 4      | Enrollment progress.  |
5413| SENSOR_INFO<sup>10+</sup> | 5      | Sensor information.  |
5414| NEXT_PHASE_FREEZING_TIME<sup>12+</sup> | 6 | Next freezing time.|
5415
5416## SetPropertyType<sup>8+</sup>
5417
5418Enumerates the types of properties to set.
5419
5420**System API**: This is a system API.
5421
5422**System capability**: SystemCapability.Account.OsAccount
5423
5424| Name          | Value| Description       |
5425| -------------- | ----- | ----------- |
5426| INIT_ALGORITHM | 1     | Initialization algorithm.|
5427
5428## AuthType<sup>8+</sup>
5429
5430Enumerates the authentication credential types.
5431
5432**System API**: This is a system API.
5433
5434**System capability**: SystemCapability.Account.OsAccount
5435
5436| Name | Value| Description            |
5437| ----- | ----- | ---------------- |
5438| PIN   | 1     | PIN authentication.|
5439| FACE  | 2     | Facial authentication.|
5440| FINGERPRINT<sup>10+</sup>   | 4     | Fingerprint authentication.|
5441| RECOVERY_KEY<sup>12+</sup> | 8 | Key recovery type.|
5442| DOMAIN<sup>9+</sup>  | 1024     | Domain authentication.|
5443
5444## AuthSubType<sup>8+</sup>
5445
5446Enumerates the authentication credential subtypes.
5447
5448**System API**: This is a system API.
5449
5450**System capability**: SystemCapability.Account.OsAccount
5451
5452| Name      | Value| Description              |
5453| ---------- | ----- | ------------------ |
5454| PIN_SIX    | 10000 | Six-digit PIN.      |
5455| PIN_NUMBER | 10001 | Custom PIN.|
5456| PIN_MIXED  | 10002 | Custom mixed credentials.|
5457| PIN_FOUR<sup>12+</sup>   | 10003 | 4-digit credential.|
5458| PIN_PATTERN<sup>12+</sup>  | 10004 | Pattern credential.|
5459| FACE_2D    | 20000 | 2D face credential.  |
5460| FACE_3D    | 20001 | 3D face credential.  |
5461| FINGERPRINT_CAPACITIVE<sup>10+</sup>    | 30000 | Capacitive fingerprint.  |
5462| FINGERPRINT_OPTICAL<sup>10+</sup>    | 30001 | Optical fingerprint.  |
5463| FINGERPRINT_ULTRASONIC<sup>10+</sup>    | 30002 | Ultrasonic fingerprint.  |
5464| DOMAIN_MIXED<sup>9+</sup>    | 10240001 | Mixed domain authentication credentials.  |
5465
5466## AuthTrustLevel<sup>8+</sup>
5467
5468Enumerates the trust levels of the authentication result.
5469
5470**System API**: This is a system API.
5471
5472**System capability**: SystemCapability.Account.OsAccount
5473
5474| Name | Value| Description       |
5475| ---- | ------ | ----------- |
5476| ATL1 | 10000  | Trust level 1.|
5477| ATL2 | 20000  | Trust level 2.|
5478| ATL3 | 30000  | Trust level 3.|
5479| ATL4 | 40000  | Trust level 4.|
5480
5481## Module<sup>8+</sup>
5482
5483Enumerates the modules from which information is obtained.
5484
5485**System API**: This is a system API.
5486
5487**System capability**: SystemCapability.Account.OsAccount
5488
5489| Name      | Value| Description                    |
5490| --------- | ------ | ------------------------ |
5491| FACE_AUTH | 1      | Facial authentication module.|
5492
5493## ResultCode<sup>8+</sup>
5494
5495Enumerates the authentication result codes.
5496
5497**System API**: This is a system API.
5498
5499**System capability**: SystemCapability.Account.OsAccount
5500
5501| Name                   | Value| Description                                    |
5502| ----------------------- | ----- | ---------------------------------------- |
5503| SUCCESS                 | 0     | The authentication is successful or the authentication feature is supported.            |
5504| FAIL                    | 1     | The authentication executor failed to identify the user.                  |
5505| GENERAL_ERROR           | 2     | Other errors.                           |
5506| CANCELED                | 3     | The authentication is canceled.                      |
5507| TIMEOUT                 | 4     | The authentication timed out.                      |
5508| TYPE_NOT_SUPPORT        | 5     | The authentication credential type is not supported.                |
5509| TRUST_LEVEL_NOT_SUPPORT | 6     | The authentication trust level is not supported.              |
5510| BUSY                    | 7     | The authentication executor is busy. Try again after a few seconds.|
5511| INVALID_PARAMETERS      | 8     | Incorrect parameters are detected.                         |
5512| LOCKED                  | 9     | The authentication executor is locked.                    |
5513| NOT_ENROLLED            | 10    | The authentication executor is not enrolled.                  |
5514
5515## FaceTipsCode<sup>8+</sup>
5516
5517Enumerates the tip codes for facial authentication.
5518
5519**System API**: This is a system API.
5520
5521**System capability**: SystemCapability.Account.OsAccount
5522
5523| Name                         | Value| Description                                    |
5524| ----------------------------- | ----- | ---------------------------------------- |
5525| FACE_AUTH_TIP_TOO_BRIGHT      | 1     | The obtained face image is too bright.        |
5526| FACE_AUTH_TIP_TOO_DARK        | 2     | The obtained face image is too dark.      |
5527| FACE_AUTH_TIP_TOO_CLOSE       | 3     | The face is too close to the device.                      |
5528| FACE_AUTH_TIP_TOO_FAR         | 4     | The face is too far away from the device.                      |
5529| FACE_AUTH_TIP_TOO_HIGH        | 5     | Only the upper part of the face is captured because the device is angled too high.             |
5530| FACE_AUTH_TIP_TOO_LOW         | 6     | Only the lower part of the face is captured because the device is angled too low.             |
5531| FACE_AUTH_TIP_TOO_RIGHT       | 7     | Only the right part of the face is captured because the device is angled too much to the right.|
5532| FACE_AUTH_TIP_TOO_LEFT        | 8     | Only the left part of the face is captured because the device is angled too much to the left.|
5533| FACE_AUTH_TIP_TOO_MUCH_MOTION | 9     | The face moves too fast during facial information collection.        |
5534| FACE_AUTH_TIP_POOR_GAZE       | 10    | The face is not facing the device.                        |
5535| FACE_AUTH_TIP_NOT_DETECTED    | 11    | No face is detected.                        |
5536
5537## FingerprintTips<sup>8+</sup>
5538
5539Enumerates the tip codes for fingerprint authentication.
5540
5541**System API**: This is a system API.
5542
5543**System capability**: SystemCapability.Account.OsAccount
5544
5545| Name                         | Value| Description                                           |
5546| ----------------------------- | ----- | ----------------------------------------------- |
5547| FINGERPRINT_TIP_GOOD          | 0     | The captured image is clear.                             |
5548| FINGERPRINT_TIP_IMAGER_DIRTY  | 1     | The fingerprint image has big noise due to dirt on the sensor.|
5549| FINGERPRINT_TIP_INSUFFICIENT  | 2     | Failed to process the fingerprint image due to big noise.  |
5550| FINGERPRINT_TIP_PARTIAL       | 3     | Only part of the fingerprint image is detected.                        |
5551| FINGERPRINT_TIP_TOO_FAST      | 4     | The fingerprint image is incomplete due to quick motion.                 |
5552| FINGERPRINT_TIP_TOO_SLOW      | 5     | Failed to read the fingerprint image due to lack of motion.               |
5553| FINGERPRINT_TIP_FINGER_DOWN<sup>10+</sup>   | 6     | Press your finger.                 |
5554| FINGERPRINT_TIP_FINGER_UP<sup>10+</sup>     | 7     | Lift your finger.               |
5555
5556## OsAccountInfo
5557
5558Represents the system account information.
5559
5560**System capability**: SystemCapability.Account.OsAccount
5561
5562| Name     | Type  | Mandatory| Description      |
5563| ----------- | ------ | ---- | ---------- |
5564| shortName<sup>12+</sup> | string | No  | Short name of the system account.<br>**System API**: This is a system API and is left blank by default. |
5565| isLoggedIn<sup>12+</sup> | boolean | No  | Whether the system account is logged in.<br>**System API**: This is a system API. The default value is **false**. |
5566
5567## OsAccountType
5568
5569Enumerates the system account types.
5570
5571**System capability**: SystemCapability.Account.OsAccount
5572
5573| Name  | Value| Description        |
5574| ------ | ------ | ----------- |
5575| PRIVATE<sup>12+</sup> | 1024  | Privacy account. Only one privacy account is allowed.<br>**System API**: This is a system API. |
5576
5577## DomainAccountInfo<sup>8+</sup>
5578
5579Represents domain account information.
5580
5581**System capability**: SystemCapability.Account.OsAccount
5582
5583| Name     | Type  | Mandatory| Description      |
5584| ----------- | ------ | ---- | ---------- |
5585| accountId<sup>10+</sup> | string | No  | Domain account ID.<br>**System API**: This is a system API and is **undefined** by default. |
5586| isAuthenticated<sup>11+</sup>| boolean | No| Whether the domain account has been authenticated.<br>**System API**: This is a system API. The default value is **false**. |
5587| serverConfigId<sup>12+</sup>| boolean | No| ID of the server to which the domain account belongs.<br>**System API**: This is a system API and is **undefined** by default. |
5588
5589## ConstraintSourceTypeInfo<sup>9+</sup>
5590
5591Defines the constraint source type.
5592
5593**System API**: This is a system API.
5594
5595**System capability**: SystemCapability.Account.OsAccount
5596
5597| Name     | Type  | Mandatory| Description      |
5598| ----------- | ------ | ---- | ---------- |
5599| localId      | number | Yes  | ID of the target system account.    |
5600| type | [ConstraintSourceType](#constraintsourcetype9) | Yes  | Type of the constrain source.|
5601
5602## ConstraintSourceType<sup>9+</sup>
5603
5604Enumerates the constraint sources.
5605
5606**System API**: This is a system API.
5607
5608**System capability**: SystemCapability.Account.OsAccount
5609
5610| Name  | Value| Description        |
5611| ------ | ------ | ------------ |
5612| CONSTRAINT_NOT_EXIST  | 0      | The constraint does not exist.|
5613| CONSTRAINT_TYPE_BASE | 1      | Constraint from system settings.  |
5614| CONSTRAINT_TYPE_DEVICE_OWNER  | 2   | Constraint from the device owners' settings.  |
5615| CONSTRAINT_TYPE_PROFILE_OWNER  | 3  | Constraint from the profile owners' settings.  |
5616
5617## AuthStatusInfo<sup>10+</sup>
5618
5619Presents the authentication status information.
5620
5621**System API**: This is a system API.
5622
5623**System capability**: SystemCapability.Account.OsAccount
5624
5625| Name     | Type  | Mandatory| Description      |
5626| ----------- | ------ | ---- | ---------- |
5627| remainTimes  | number | Yes  | Number of remaining authentication times.  |
5628| freezingTime | number | Yes  | Freezing time.|
5629
5630## GetDomainAccessTokenOptions<sup>10+</sup>
5631
5632Defines the options for obtaining a domain access token.
5633
5634**System API**: This is a system API.
5635
5636**System capability**: SystemCapability.Account.OsAccount
5637
5638| Name     | Type  | Mandatory| Description      |
5639| ----------- | ------ | ---- | ---------- |
5640| domainAccountInfo  | [DomainAccountInfo](#domainaccountinfo8) | Yes  | Domain account information.  |
5641| domainAccountToken | Uint8Array | Yes  | Token of the domain account.|
5642| businessParams | Record<string, Object> | Yes  | Service parameters customized by the service party based on the request protocol.|
5643| callerUid | number | Yes  | Unique identifier of the caller.|
5644
5645## GetDomainAccountInfoOptions<sup>10+</sup>
5646
5647Defines the options for obtaining domain account information.
5648
5649**System API**: This is a system API.
5650
5651**System capability**: SystemCapability.Account.OsAccount
5652
5653| Name     | Type  | Mandatory| Description      |
5654| ----------- | ------ | ---- | ---------- |
5655| accountName | string | Yes  | Domain account name.|
5656| domain      | string | No  | Domain name, which is **undefined** by default.|
5657| serverConfigId<sup>12+</sup>| boolean | No| ID of the server to which the domain account belongs. The default value is **undefined**.|
5658
5659## GetDomainAccountInfoPluginOptions<sup>10+</sup>
5660
5661Defines the options for the domain plug-in to obtain the domain account information. The **GetDomainAccountInfoPluginOptions** class inherits from [**GetDomainAccountInfoOptions**](#getdomainaccountinfooptions10).
5662
5663**System API**: This is a system API.
5664
5665**System capability**: SystemCapability.Account.OsAccount
5666
5667| Name     | Type  | Mandatory| Description      |
5668| ----------- | ------ | ---- | ---------- |
5669| callerUid | number | Yes  | Unique identifier of the caller.|
5670
5671## OsAccountSwitchEventData<sup>12+</sup>
5672
5673Defines the event that indicates the start or end of a foreground-background system account switchover.
5674
5675**System API**: This is a system API.
5676
5677**System capability**: SystemCapability.Account.OsAccount
5678
5679| Name     | Type  | Mandatory| Description      |
5680| ----------- | ------ | ---- | ---------- |
5681| fromAccountId | number | Yes  | System account ID before the switchover.|
5682| toAccountId | number | Yes  | System account ID after the switchover.|
5683
5684## CreateOsAccountOptions<sup>12+</sup>
5685
5686Represents the optional parameter used to create a system account.
5687
5688**System API**: This is a system API.
5689
5690**System capability**: SystemCapability.Account.OsAccount
5691
5692| Name     | Type  | Mandatory| Description      |
5693| ----------- | ------ | ---- | ---------- |
5694| shortName | string | Yes  | Short name of the account (used as the name of the personal folder).<br>**The short name cannot**:<br>Contain any of the following characters: \< \>\| : " * ? / \\<br>Contain any of the following: . or ..<br>Exceed 255 characters. |
5695
5696## CreateOsAccountForDomainOptions<sup>12+</sup>
5697
5698Represents a set of optional parameters for creating a system account bound to the specified domain account. It inherits from [CreateOsAccountOptions](#createosaccountoptions12).
5699
5700**System API**: This is a system API.
5701
5702**System capability**: SystemCapability.Account.OsAccount
5703
5704| Name     | Type  | Mandatory| Description      |
5705| ----------- | ------ | ---- | ---------- |
5706| shortName | string | Yes  | Short name of the account (used as the name of the personal folder).<br>**The short name cannot**:<br>Contain any of the following characters: \< \>\| : " * ? / \\<br>Contain any of the following: . or ..<br>Exceed 255 characters. |
5707
5708## GetAuthInfoOptions<sup>12+</sup>
5709
5710Represents a set of optional parameters for [GetAuthInfo](#getauthinfo12).
5711
5712**System API**: This is a system API.
5713
5714**System capability**: SystemCapability.Account.OsAccount
5715
5716| Name     | Type                   | Mandatory| Description      |
5717| --------- | ---------------------- | ---- | ---------- |
5718| authType  | [AuthType](#authtype8) | No  | Authentication type, which is **undefined** by default.|
5719| accountId | number                 | No  | System account ID, which is **undefined** by default.|
5720
5721## AuthIntent<sup>12+</sup>
5722
5723Enumerates the authentication intents.
5724
5725**System API**: This is a system API.
5726
5727**System capability**: SystemCapability.Account.OsAccount
5728
5729| Name    | Value  | Description      |
5730| -------- | --- | ---------- |
5731| UNLOCK   | 1   | Unlock.|
5732
5733## RemoteAuthOptions<sup>12+</sup>
5734
5735Represents a set of optional parameters for remote authentication.
5736
5737**System API**: This is a system API.
5738
5739**System capability**: SystemCapability.Account.OsAccount
5740
5741| Name              | Type   | Mandatory| Description      |
5742| ------------------ | ------ | ---- | ---------- |
5743| verifierNetworkId  | string | No  | Network ID of the credential verifier, which is left blank by default.|
5744| collectorNetworkId | string | No  | Network ID of the credential collector, which is left blank by default.|
5745| collectorTokenId   | number | No  | Token ID of the credential collector, which is **undefined** by default.|
5746
5747## AuthOptions<sup>12+</sup>
5748
5749Represents a set of optional parameters for [auth](#auth12).
5750
5751**System API**: This is a system API.
5752
5753**System capability**: SystemCapability.Account.OsAccount
5754
5755| Name              | Type   | Mandatory| Description      |
5756| ------------------ | ------ | ---- | ---------- |
5757| accountId          | number | No  | System account ID, which is **undefined** by default.|
5758| authIntent         | [AuthIntent](#authintent12) | No  | Authentication intent, which is **undefined** by default.|
5759| remoteAuthOptions  | [RemoteAuthOptions](#remoteauthoptions12) | No  | Remote authentication options, which is **undefined** by default.|
5760
5761## GetInputDataOptions <sup>12+</sup>
5762
5763Represents a set of optional parameters for [onGetData](#ongetdata8).
5764
5765**System API**: This is a system API.
5766
5767**System capability**: SystemCapability.Account.OsAccount
5768
5769| Name              | Type   | Mandatory| Description      |
5770| ------------------ | ------ | ---- | ---------- |
5771| challenge          | Uint8Array | No  | Challenge value, which is **undefined** by default.|
5772