1# @ohos.account.osAccount (系统账号管理)(系统接口)
2
3本模块提供管理系统账号的基础能力,包括系统账号的添加、删除、查询、设置、订阅、启动等功能。
4
5> **说明:**
6>
7> - 本模块首批接口从API version 7开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
8> - 当前页面仅包含本模块的系统接口,其他公开接口参见[ohos.account.osAccount (系统账号管理)](js-apis-osAccount.md)。
9
10## 导入模块
11
12```ts
13import { osAccount } from '@kit.BasicServicesKit';
14```
15
16## AccountManager
17
18系统账号管理类。
19
20### activateOsAccount
21
22activateOsAccount(localId: number, callback: AsyncCallback<void>): void
23
24激活指定系统账号。使用callback异步回调。
25
26**系统接口:** 此接口为系统接口。
27
28**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
29
30**系统能力:** SystemCapability.Account.OsAccount
31
32**参数:**
33
34| 参数名   | 类型                       | 必填 | 说明                                                |
35| -------- | ------------------------- | ---- | -------------------------------------------------- |
36| localId  | number                    | 是   | 系统账号ID。                  |
37| callback | AsyncCallback<void> | 是   | 回调函数。当账号激活成功时,err为null,否则为错误对象。 |
38
39**错误码:**
40
41| 错误码ID | 错误信息             |
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**示例:** 激活ID为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
73激活指定系统账号。使用Promise异步回调。
74
75**系统接口:** 此接口为系统接口。
76
77**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
78
79**系统能力:** SystemCapability.Account.OsAccount
80
81**参数:**
82
83| 参数名  | 类型   | 必填 | 说明                 |
84| ------- | ------ | ---- | -------------------- |
85| localId | number | 是   | 系统账号ID。 |
86
87**返回值:**
88
89| 类型                | 说明                                  |
90| ------------------- | ------------------------------------ |
91| Promise<void> | Promise对象,无返回结果的Promise对象。 |
92
93**错误码:**
94
95| 错误码ID | 错误信息             |
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**示例:** 激活ID为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
126注销(退出登录)指定系统账号。使用Promise异步回调。
127
128**系统接口:** 此接口为系统接口。
129
130**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
131
132**系统能力:** SystemCapability.Account.OsAccount
133
134**参数:**
135
136| 参数名  | 类型   | 必填 | 说明                 |
137| ------- | ------ | ---- | -------------------- |
138| localId | number | 是   | 系统账号ID。 |
139
140**返回值:**
141
142| 类型                | 说明                                  |
143| ------------------- | ------------------------------------ |
144| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
145
146**错误码:**
147
148| 错误码ID | 错误信息             |
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**示例:** 注销ID为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
177判断指定系统账号是否处于激活状态。使用Promise异步回调。
178
179**系统接口:** 此接口为系统接口。
180
181**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
182
183**系统能力:** SystemCapability.Account.OsAccount
184
185**参数:**
186
187| 参数名  | 类型   | 必填 | 说明                               |
188| ------- | ------ | ---- | --------------------------------- |
189| localId | number | 是   | 系统账号ID。 |
190
191**返回值:**
192
193| 类型                   | 说明                                                       |
194| ---------------------- | ---------------------------------------------------------- |
195| Promise&lt;boolean&gt; | Promise对象。返回true表示账号已激活;返回false表示账号未激活。 |
196
197**错误码:**
198
199| 错误码ID | 错误信息             |
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**示例:** 判断ID为100的系统账号是否处于激活状态
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
228判断指定系统账号是否使能指定约束。使用Promise异步回调。
229
230**系统接口:** 此接口为系统接口。
231
232**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
233
234**系统能力:** SystemCapability.Account.OsAccount
235
236**参数:**
237
238| 参数名     | 类型   | 必填 | 说明                                |
239| ---------- | ------ | ---- | ---------------------------------- |
240| localId    | number | 是   | 系统账号ID。  |
241| constraint | string | 是   | 指定的[约束](js-apis-osAccount.md#系统账号约束列表)名称。 |
242
243**返回值:**
244
245| 类型                   | 说明                                                                  |
246| --------------------- | --------------------------------------------------------------------- |
247| Promise&lt;boolean&gt; | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
248
249**错误码:**
250
251| 错误码ID | 错误信息             |
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**示例:** 判断ID为100的系统账号是否有禁止使用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
281检查指定系统账号是否已验证。使用Promise异步回调。
282
283**系统接口:** 此接口为系统接口。
284
285**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
286
287**系统能力:** SystemCapability.Account.OsAccount
288
289**参数:**
290
291| 参数名  | 类型   | 必填 | 说明                                                              |
292| ------- | ------ | ---- | --------------------------------------------------------------- |
293| localId | number | 是   | 系统账号ID。不填则检查当前系统账号是否已验证。 |
294
295**返回值:**
296
297| 类型                   | 说明                                                               |
298| ---------------------- | ----------------------------------------------------------------- |
299| Promise&lt;boolean&gt; | Promise对象。返回true表示当前账号已认证解锁;返回false表示当前账号未认证解锁。 |
300
301**错误码:**
302
303| 错误码ID | 错误信息             |
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**示例:**
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
332删除指定系统账号。使用callback异步回调。
333
334**系统接口:** 此接口为系统接口。
335
336**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
337
338**系统能力:** SystemCapability.Account.OsAccount
339
340**参数:**
341
342| 参数名   | 类型                      | 必填 | 说明                                                 |
343| -------- | ------------------------- | ---- | -------------------------------------------------- |
344| localId  | number                    | 是   | 系统账号ID。                  |
345| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。如果删除账号成功,err为null,否则为错误对象。 |
346
347**错误码:**
348
349| 错误码ID | 错误信息             |
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**示例:**
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
385删除指定系统账号。使用Promise异步回调。
386
387**系统接口:** 此接口为系统接口。
388
389**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
390
391**系统能力:** SystemCapability.Account.OsAccount
392
393**参数:**
394
395| 参数名  | 类型   | 必填 | 说明                               |
396| ------- | ------ | ---- | --------------------------------- |
397| localId | number | 是   | 系统账号ID。 |
398
399**返回值:**
400
401| 类型                | 说明                                  |
402| ------------------- | ------------------------------------ |
403| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
404
405**错误码:**
406
407| 错误码ID | 错误信息             |
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**示例:**
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
441为指定系统账号设置/删除约束。使用callback异步回调。
442
443**系统接口:** 此接口为系统接口。
444
445**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
446
447**系统能力:** SystemCapability.Account.OsAccount
448
449**参数:**
450
451| 参数名      | 类型                      | 必填 | 说明                                             |
452| ----------- | ------------------------- | ---- | ----------------------------------------------- |
453| localId     | number                    | 是   | 系统账号ID。               |
454| constraints | Array&lt;string&gt;       | 是   | 待设置/删除的[约束](js-apis-osAccount.md#系统账号约束列表)列表。        |
455| enable      | boolean                   | 是   | 设置(true)/删除(false)                           |
456| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。如果设置成功,err为null,否则为错误对象。 |
457
458**错误码:**
459
460| 错误码ID | 错误信息             |
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**示例:** 给ID为100的系统账号设置禁止使用Wi-Fi的约束
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
494为指定系统账号设置/删除约束。使用Promise异步回调。
495
496**系统接口:** 此接口为系统接口。
497
498**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
499
500**系统能力:** SystemCapability.Account.OsAccount
501
502**参数:**
503
504| 参数名      | 类型                | 必填 | 说明                                         |
505| ----------- | ------------------- | ---- | -------------------------------------------- |
506| localId     | number              | 是   | 系统账号ID。           |
507| constraints | Array&lt;string&gt; | 是   | 待设置/删除的[约束](js-apis-osAccount.md#系统账号约束列表)列表。    |
508| enable      | boolean             | 是   | 设置(true)/删除(false)。                     |
509
510**返回值:**
511
512| 类型                | 说明                                 |
513| :------------------ | :----------------------------------- |
514| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
515
516**错误码:**
517
518| 错误码ID | 错误信息             |
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**示例:** 删除ID为100的系统账号的禁止使用Wi-Fi的约束
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
549设置指定系统账号的账号名。使用callback异步回调。
550
551**系统接口:** 此接口为系统接口。
552
553**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
554
555**系统能力:** SystemCapability.Account.OsAccount
556
557**参数:**
558
559| 参数名    | 类型                      | 必填 | 说明                                             |
560| :-------- | ------------------------- | ---- | ----------------------------------------------- |
561| localId   | number                    | 是   | 系统账号ID。               |
562| localName | string                    | 是   | 账号名,最大长度为1024个字符。                          |
563| callback  | AsyncCallback&lt;void&gt; | 是   | 回调函数。如果设置成功,err为null,否则为错误对象。 |
564
565**错误码:**
566
567| 错误码ID | 错误信息             |
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**示例:** 将ID为100的系统账号的账号名设置成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
601设置指定系统账号的账号名。使用Promise异步调用。
602
603**系统接口:** 此接口为系统接口。
604
605**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
606
607**系统能力:** SystemCapability.Account.OsAccount
608
609**参数:**
610
611| 参数名    | 类型   | 必填 | 说明                                |
612| --------- | ------ | ---- | --------------------------------- |
613| localId   | number | 是   | 系统账号ID。 |
614| localName | string | 是   | 账号名,最大长度为1024。            |
615
616**返回值:**
617
618| 类型                | 说明                                  |
619| ------------------- | ------------------------------------ |
620| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
621
622**错误码:**
623
624| 错误码ID | 错误信息             |
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**示例:** 将ID为100的系统账号的账号名设置成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
656查询允许创建的系统账号的最大数量。使用callback异步回调。
657
658**系统接口:** 此接口为系统接口。
659
660**系统能力:** SystemCapability.Account.OsAccount
661
662**参数:**
663
664| 参数名   | 类型                        | 必填 | 说明                                                                              |
665| -------- | --------------------------- | ---- | -------------------------------------------------------------------------------- |
666| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数,如果查询成功,err为null,data为允许创建的系统账号的最大数量;否则为错误对象。 |
667
668**错误码:**
669
670| 错误码ID | 错误信息       |
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**示例:**
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
698查询允许创建的系统账号的最大数量。使用Promise异步回调。
699
700**系统接口:** 此接口为系统接口。
701
702**系统能力:** SystemCapability.Account.OsAccount
703
704**返回值:**
705
706| 类型                  | 说明                                         |
707| --------------------- | ------------------------------------------- |
708| Promise&lt;number&gt; | Promise对象,返回允许创建的系统账号的最大数量。 |
709
710**错误码:**
711
712| 错误码ID | 错误信息       |
713| -------- | ------------- |
714| 202 | Not system application.|
715| 12300001 | The system service works abnormally. |
716
717**示例:**
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
737查询允许同时登录的系统账号的最大数量。使用Promise异步回调。
738
739**系统接口:** 此接口为系统接口。
740
741**系统能力:** SystemCapability.Account.OsAccount
742
743**返回值:**
744
745| 类型                  | 说明                                         |
746| --------------------- | ------------------------------------------- |
747| Promise&lt;number&gt; | Promise对象,返回允许登录的系统账号的最大数量。 |
748
749**错误码:**
750
751| 错误码ID | 错误信息       |
752| -------- | ------------- |
753| 202 | Not system application.|
754| 12300001 | The system service works abnormally. |
755
756**示例:**
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
776获取指定系统账号已使能的的全部约束。使用Promise异步回调。
777
778**系统接口:** 此接口为系统接口。
779
780**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
781
782**系统能力:** SystemCapability.Account.OsAccount
783
784**参数:**
785
786| 参数名  | 类型   | 必填 | 说明         |
787| ------- | ------ | ---- | ------------ |
788| localId | number | 是   | 系统账号ID。 |
789
790**返回值:**
791
792| 类型                               | 说明                                                       |
793| ---------------------------------- | ---------------------------------------------------------- |
794| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回指定系统账号已使能的的全部[约束](js-apis-osAccount.md#系统账号约束列表)。 |
795
796**错误码:**
797
798| 错误码ID | 错误信息             |
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**示例:** 获取ID为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
827查询已创建的所有系统账号的信息列表。使用callback异步回调。
828
829**系统接口:** 此接口为系统接口。
830
831**系统能力:** SystemCapability.Account.OsAccount
832
833**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
834
835**参数:**
836
837| 参数名   | 类型                                                         | 必填 | 说明                                               |
838| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
839| callback | AsyncCallback&lt;Array&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt;&gt; | 是   | 回调函数。如果查询成功,err为null,data为已创建的所有系统账号的信息列表;否则为错误对象。 |
840
841**错误码:**
842
843| 错误码ID | 错误信息       |
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**示例:**
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
869查询已创建的所有系统账号的信息列表。使用Promise异步回调。
870
871**系统接口:** 此接口为系统接口。
872
873**系统能力:** SystemCapability.Account.OsAccount
874
875**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
876
877**返回值:**
878
879| 类型                                                        | 说明                                           |
880| ----------------------------------------------------------- | --------------------------------------------- |
881| Promise&lt;Array&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt;&gt; | Promise对象,返回已创建的所有系统账号的信息列表。 |
882
883**错误码:**
884
885| 错误码ID | 错误信息       |
886| -------- | ------------- |
887| 201 | Permission denied.|
888| 202 | Not system application.|
889| 12300001 | The system service works abnormally. |
890
891**示例:**
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
911获取前台系统账号的ID。
912
913**系统接口:** 此接口为系统接口。
914
915**系统能力:** SystemCapability.Account.OsAccount
916
917**返回值:**
918
919| 类型                   | 说明                                                               |
920| ---------------------- | ----------------------------------------------------------------- |
921| Promise&lt;number&gt; | Promise对象。返回前台系统账号的ID。 |
922
923**错误码:**
924
925| 错误码ID | 错误信息       |
926| -------- | ------------- |
927| 202 | Not system application.|
928| 12300001 | The system service works abnormally. |
929
930**示例:**
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
950创建一个系统账号。使用callback异步回调。
951
952**系统接口:** 此接口为系统接口。
953
954**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
955
956**系统能力:** SystemCapability.Account.OsAccount
957
958**参数:**
959
960| 参数名    | 类型                                                 | 必填 | 说明                                                                         |
961| :-------- | ---------------------------------------------------- | ---- | --------------------------------------------------------------------------- |
962| localName | string                                               | 是   | 创建的系统账号的名称。                                                        |
963| type      | [OsAccountType](js-apis-osAccount.md#osaccounttype)                      | 是   | 创建的系统账号的类型。                                                        |
964| callback  | AsyncCallback&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | 是   | 回调函数。如果创建成功,err为null,data为新创建的系统账号的信息;否则为错误对象。 |
965
966**错误码:**
967
968| 错误码ID  | 错误信息                   |
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**示例:**
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
1000创建一个系统账号。使用Promise异步回调。
1001
1002**系统接口:** 此接口为系统接口。
1003
1004**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1005
1006**系统能力:** SystemCapability.Account.OsAccount
1007
1008**参数:**
1009
1010| 参数名    | 类型                            | 必填 | 说明                   |
1011| --------- | ------------------------------- | ---- | ---------------------- |
1012| localName | string                          | 是   | 创建的系统账号的名称。 |
1013| type      | [OsAccountType](js-apis-osAccount.md#osaccounttype) | 是   | 创建的系统账号的类型。 |
1014| options      | [CreateOsAccountOptions](js-apis-osAccount-sys.md#createosaccountoptions12) | 否   | 创建系统账号的选项,默认为空。 <br/>从API version 12开始支持该可选参数。|
1015
1016**返回值:**
1017
1018| 类型                                           | 说明                                  |
1019| ---------------------------------------------- | ------------------------------------- |
1020| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise对象,返回新创建的系统账号的信息。 |
1021
1022**错误码:**
1023
1024| 错误码ID  | 错误信息                   |
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**示例:**
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
1061根据域账号信息,创建一个系统账号并将其与域账号关联。使用callback异步回调。
1062
1063**系统接口:** 此接口为系统接口。
1064
1065**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1066
1067**系统能力:** SystemCapability.Account.OsAccount
1068
1069**参数:**
1070
1071| 参数名     | 类型                                                 | 必填 | 说明                                                                         |
1072| ---------- | ---------------------------------------------------- | ---- | -------------------------------------------------------------------------- |
1073| type       | [OsAccountType](js-apis-osAccount.md#osaccounttype)                      | 是   | 创建的系统账号的类型。                                                       |
1074| domainInfo | [DomainAccountInfo](#domainaccountinfo8)              | 是   | 域账号信息。                                                               |
1075| callback   | AsyncCallback&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | 是   | 回调函数。如果创建成功,err为null,data为新创建的系统账号的信息;否则为错误对象。 |
1076
1077**错误码:**
1078
1079| 错误码ID | 错误信息                     |
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**示例:**
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
1114根据传入的域账号信息,创建与其关联的系统账号。使用Promise异步回调。
1115
1116**系统接口:** 此接口为系统接口。
1117
1118**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1119
1120**系统能力:** SystemCapability.Account.OsAccount
1121
1122**参数:**
1123
1124| 参数名     | 类型                                      | 必填 | 说明                 |
1125| ---------- | ---------------------------------------- | ---- | -------------------- |
1126| type       | [OsAccountType](js-apis-osAccount.md#osaccounttype)          | 是   | 创建的系统账号的类型。 |
1127| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号信息。          |
1128| options      | [CreateOsAccountForDomainOptions](#createosaccountfordomainoptions12) | 否   | 创建账号的可选参数,默认为空。 <br/>从API version 12开始支持该可选参数。|
1129
1130**返回值:**
1131
1132| 类型                                           | 说明                                    |
1133| ---------------------------------------------- | -------------------------------------- |
1134| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise对象,返回新创建的系统账号的信息。 |
1135
1136**错误码:**
1137
1138| 错误码ID | 错误信息                     |
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**示例:**
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
1178查询当前进程所属的系统账号的信息。使用Promise异步回调。
1179
1180**系统接口:** 此接口为系统接口。
1181
1182**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.GET_LOCAL_ACCOUNTS
1183
1184**系统能力:** SystemCapability.Account.OsAccount
1185
1186**返回值:**
1187
1188| 类型                                           | 说明                                       |
1189| ---------------------------------------------- | ----------------------------------------- |
1190| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise对象,返回当前进程所属的系统账号信息。 |
1191
1192**错误码:**
1193
1194| 错误码ID | 错误信息             |
1195| -------- | ------------------- |
1196| 201 | Permission denied.|
1197| 202 | Not system application.|
1198| 12300001 | The system service works abnormally. |
1199
1200**示例:**
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
1220查询指定系统账号的信息。使用callback异步回调。
1221
1222**系统接口:** 此接口为系统接口。
1223
1224**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1225
1226**系统能力:** SystemCapability.Account.OsAccount
1227
1228**参数:**
1229
1230| 参数名   | 类型                                                 | 必填 | 说明                                                                       |
1231| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------------------ |
1232| localId  | number                                               | 是   | 要查询的系统账号的ID。                                                      |
1233| callback | AsyncCallback&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | 是   | 回调函数。如果查询成功,err为null,data为查到的系统账号的信息;否则为错误对象。 |
1234
1235**错误码:**
1236
1237| 错误码ID | 错误信息             |
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**示例:** 查询ID为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
1266查询指定系统账号的信息。使用Promise异步回调。
1267
1268**系统接口:** 此接口为系统接口。
1269
1270**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1271
1272**系统能力:** SystemCapability.Account.OsAccount
1273
1274**参数:**
1275
1276| 参数名  | 类型   | 必填 | 说明                 |
1277| ------- | ------ | ---- | -------------------- |
1278| localId | number | 是   | 要查询的系统账号的ID |
1279
1280**返回值:**
1281
1282| 类型                                           | 说明                                 |
1283| ---------------------------------------------- | ------------------------------------ |
1284| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise对象,返回查到的系统账号的信息。 |
1285
1286**错误码:**
1287
1288| 错误码ID | 错误信息             |
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**示例:** 查询ID为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
1318获取指定系统账号的头像信息。使用callback异步回调。
1319
1320**系统接口:** 此接口为系统接口。
1321
1322**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1323
1324**系统能力:** SystemCapability.Account.OsAccount
1325
1326**参数:**
1327
1328| 参数名   | 类型                        | 必填 | 说明                                                                         |
1329| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
1330| localId  | number                      | 是   | 系统账号ID。                                                                |
1331| callback | AsyncCallback&lt;string&gt; | 是   | 回调函数。如果获取成功,err为null,data为指定系统账号的头像信息;否则为错误对象。 |
1332
1333**错误码:**
1334
1335| 错误码ID | 错误信息             |
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**示例:** 获取ID为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
1364获取指定系统账号的头像信息。使用Promise异步回调。
1365
1366**系统接口:** 此接口为系统接口。
1367
1368**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1369
1370**系统能力:** SystemCapability.Account.OsAccount
1371
1372**参数:**
1373
1374| 参数名  | 类型   | 必填 | 说明         |
1375| ------- | ------ | ---- | ------------ |
1376| localId | number | 是   | 系统账号ID。 |
1377
1378**返回值:**
1379
1380| 类型                  | 说明                                    |
1381| --------------------- | -------------------------------------- |
1382| Promise&lt;string&gt; | Promise对象,返回指定系统账号的头像信息。 |
1383
1384**错误码:**
1385
1386| 错误码ID | 错误信息             |
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**示例:** 获取ID为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
1416为指定系统账号设置头像信息。使用callback异步回调。
1417
1418**系统接口:** 此接口为系统接口。
1419
1420**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1421
1422**系统能力:** SystemCapability.Account.OsAccount
1423
1424**参数:**
1425
1426| 参数名   | 类型                      | 必填 | 说明         |
1427| -------- | ------------------------- | ---- | ------------ |
1428| localId  | number                    | 是   | 系统账号ID。 |
1429| photo    | string                    | 是   | 头像信息。   |
1430| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。如果设置成功,err为null,否则为错误对象。  |
1431
1432**错误码:**
1433
1434| 错误码ID | 错误信息             |
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**示例:** 给ID为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
1467为指定系统账号设置头像信息。使用Promise异步回调。
1468
1469**系统接口:** 此接口为系统接口。
1470
1471**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1472
1473**系统能力:** SystemCapability.Account.OsAccount
1474
1475**参数:**
1476
1477| 参数名  | 类型   | 必填 | 说明         |
1478| ------- | ------ | ---- | ------------ |
1479| localId | number | 是   | 系统账号ID。 |
1480| photo   | string | 是   | 头像信息。   |
1481
1482**返回值:**
1483
1484| 类型                | 说明                                 |
1485| ------------------- | ------------------------------------ |
1486| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
1487
1488**错误码:**
1489
1490| 错误码ID | 错误信息             |
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**示例:** 给ID为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
1525订阅系统账号的激活完成与激活中的事件。使用callback异步回调。
1526
1527**系统接口:** 此接口为系统接口。
1528
1529**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1530
1531**系统能力:** SystemCapability.Account.OsAccount
1532
1533**参数:**
1534
1535| 参数名   | 类型                       | 必填 | 说明                                                         |
1536| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1537| type     | 'activate' \| 'activating' | 是   | 订阅类型,activate表示订阅的是账号已激活完成的事件,activating表示订阅的是账号正在激活的事件。 |
1538| name     | string                     | 是   | 订阅名称,可自定义,要求非空且长度不超过1024字节。           |
1539| callback | Callback&lt;number&gt;     | 是   | 订阅系统账号激活完成与激活中的事件回调,表示激活完成后或正在激活中的系统账号ID。    |
1540
1541**错误码:**
1542
1543| 错误码ID | 错误信息       |
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**示例:**
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
1569取消订阅系统账号的激活完成与激活中的事件。使用callback异步回调。
1570
1571**系统接口:** 此接口为系统接口。
1572
1573**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1574
1575**系统能力:** SystemCapability.Account.OsAccount
1576
1577**参数:**
1578
1579| 参数名   | 类型                       | 必填 | 说明                                                         |
1580| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1581| type     | 'activate' \| 'activating' | 是   | 取消订阅类型,activate表示取消订阅账号已激活完成的事件,activating取消订阅账号正在激活的事件。 |
1582| name     | string                     | 是   | 订阅名称,可自定义,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 |
1583| callback | Callback&lt;number&gt;     | 否   | 取消订阅系统账号激活完成与激活中的事件回调,默认为空,表示取消该类型事件的所有回调。                      |
1584
1585**错误码:**
1586
1587| 错误码ID | 错误信息       |
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**示例:**
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
1613订阅系统账号的前后台正在切换事件。使用callback异步回调。
1614
1615**系统接口:** 此接口为系统接口。
1616
1617**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1618
1619**系统能力:** SystemCapability.Account.OsAccount
1620
1621**参数:**
1622
1623| 参数名   | 类型                       | 必填 | 说明                                                         |
1624| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1625| type     | 'switching'                 | 是   | 订阅类型,switching表示订阅的是系统账号的前后台正在切换事件。 |
1626| callback | Callback&lt;[OsAccountSwitchEventData](#osaccountswitcheventdata12)&gt;     | 是   | 订阅系统账号的前后台正在切换事件回调,表示切换前和切换后的系统账号ID。    |
1627
1628**错误码:**
1629
1630| 错误码ID | 错误信息       |
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**示例:**
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
1656取消订阅系统账号的前后台正在切换事件。使用callback异步回调。
1657
1658**系统接口:** 此接口为系统接口。
1659
1660**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1661
1662**系统能力:** SystemCapability.Account.OsAccount
1663
1664**参数:**
1665
1666| 参数名   | 类型                       | 必填 | 说明                                                         |
1667| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1668| type     | 'switching'                 | 是   | 取消订阅类型,switching表示取消订阅的是系统账号的前后台正在切换事件。 |
1669| callback | Callback&lt;[OsAccountSwitchEventData](#osaccountswitcheventdata12)&gt;     | 否   | 取消订阅系统账号的前后台正在切换事件回调,默认为空,表示取消该类型事件的所有回调。                      |
1670
1671**错误码:**
1672
1673| 错误码ID | 错误信息       |
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**示例:**
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
1696订阅系统账号的前后台切换结束事件。使用callback异步回调。
1697
1698**系统接口:** 此接口为系统接口。
1699
1700**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1701
1702**系统能力:** SystemCapability.Account.OsAccount
1703
1704**参数:**
1705
1706| 参数名   | 类型                       | 必填 | 说明                                                         |
1707| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1708| type     | 'switched'                 | 是   | 订阅类型,switched表示订阅的是系统账号的前后台切换结束事件。 |
1709| callback | Callback&lt;[OsAccountSwitchEventData](#osaccountswitcheventdata12)&gt;     | 是   | 订阅系统账号的前后台切换结束事件回调,表示切换前和切换后的系统账号ID。    |
1710
1711**错误码:**
1712
1713| 错误码ID | 错误信息       |
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**示例:**
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
1739取消订阅系统账号的前后台切换结束事件。使用callback异步回调。
1740
1741**系统接口:** 此接口为系统接口。
1742
1743**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1744
1745**系统能力:** SystemCapability.Account.OsAccount
1746
1747**参数:**
1748
1749| 参数名   | 类型                       | 必填 | 说明                                                         |
1750| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1751| type     | 'switched'                 | 是   | 取消订阅类型,switched表示取消订阅的是系统账号的前后台切换结束事件。 |
1752| callback | Callback&lt;[OsAccountSwitchEventData](#osaccountswitcheventdata12)&gt;     | 否   | 取消订阅系统账号的前后台切换结束事件回调,默认为空,表示取消该类型事件的所有回调。                      |
1753
1754**错误码:**
1755
1756| 错误码ID | 错误信息       |
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**示例:**
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
1779通过uid查询对应的bundleId,使用callback异步回调。
1780
1781**系统接口:** 此接口为系统接口。
1782
1783**系统能力:** SystemCapability.Account.OsAccount
1784
1785**参数:**
1786
1787| 参数名   | 类型                       | 必填 | 说明                                                                        |
1788| -------- | --------------------------- | ---- | ------------------------------------------------------------------------ |
1789| uid      | number                      | 是   | 进程uid。                                                                 |
1790| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果查询成功,err为null,data为与uid对应的bundleId;否则为错误对象。 |
1791
1792**错误码:**
1793
1794| 错误码ID | 错误信息       |
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**示例:**
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
1821通过uid查询对应的bundleId,使用Promise异步回调。
1822
1823**系统接口:** 此接口为系统接口。
1824
1825**系统能力:** SystemCapability.Account.OsAccount
1826
1827**参数:**
1828
1829| 参数名  | 类型   | 必填 | 说明         |
1830| ------- | ------ | ---- | ------------ |
1831| uid     | number | 是   |  进程uid。 |
1832
1833**返回值:**
1834
1835| 类型                  | 说明                                  |
1836| --------------------- | ------------------------------------ |
1837| Promise&lt;number&gt; | Promise对象,返回与uid对应的bundleId。 |
1838
1839**错误码:**
1840
1841| 错误码ID | 错误信息       |
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**示例:**
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
1869通过uid查询对应的bundleId。使用同步方式返回结果。
1870
1871**系统接口:** 此接口为系统接口。
1872
1873**系统能力:** SystemCapability.Account.OsAccount
1874
1875**参数:**
1876
1877| 参数名  | 类型   | 必填 | 说明         |
1878| ------- | ------ | ---- | ------------ |
1879| uid     | number | 是   |  进程uid。 |
1880
1881**返回值:**
1882
1883| 类型   | 说明                     |
1884| ------ | ------------------------ |
1885| number | 表示与进程uid对应的bundleId。 |
1886
1887**错误码:**
1888
1889| 错误码ID | 错误信息       |
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**示例:**
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
1912查询当前进程是否处于主用户,使用callback异步回调。
1913
1914**系统接口:** 此接口为系统接口。
1915
1916**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1917
1918**系统能力:** SystemCapability.Account.OsAccount
1919
1920**参数:**
1921
1922| 参数名   | 类型                          | 必填 | 说明                                                               |
1923| -------- | ---------------------------- | ---- | ----------------------------------------------------------------- |
1924| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数,返回true表示当前账号为主账号,返回false表示当前账号非主账号。 |
1925
1926**错误码:**
1927
1928| 错误码ID | 错误信息       |
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**示例:**
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
1954查询当前进程是否处于主用户,使用Promise异步回调。
1955
1956**系统接口:** 此接口为系统接口。
1957
1958**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1959
1960**系统能力:** SystemCapability.Account.OsAccount
1961
1962**返回值:**
1963
1964| 类型                   | 说明                                                                  |
1965| ---------------------- | --------------------------------------------------------------------- |
1966| Promise&lt;boolean&gt; | Promise对象,返回true表示当前账号为主账号,返回false表示当前账号非主账号。 |
1967
1968**错误码:**
1969
1970| 错误码ID | 错误信息       |
1971| -------- | ------------- |
1972| 201 | Permission denied.|
1973| 202 | Not system application.|
1974| 12300001 | The system service works abnormally. |
1975
1976**示例:**
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
1996查询指定系统账号的指定约束来源信息,使用callback异步回调。
1997
1998**系统接口:** 此接口为系统接口。
1999
2000**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
2001
2002**系统能力:** SystemCapability.Account.OsAccount
2003
2004**参数:**
2005
2006| 参数名   | 类型                       | 必填 | 说明                                                         |
2007| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
2008| localId     | number | 是   |  要查询的系统账号ID |
2009| constraint     | string | 是   |  要查询的[约束](js-apis-osAccount.md#系统账号约束列表)名称 |
2010| callback | AsyncCallback&lt;Array&lt;[ConstraintSourceTypeInfo](#constraintsourcetypeinfo9)&gt;&gt;     | 是   | 回调函数。如果成功,err为null,data为指定系统账号的指定[约束](js-apis-osAccount.md#系统账号约束列表)来源信息;否则为错误对象。                      |
2011
2012**错误码:**
2013
2014| 错误码ID | 错误信息       |
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**示例:**
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
2043查询指定系统账号的指定约束来源信息,使用Promise异步回调。
2044
2045**系统接口:** 此接口为系统接口。
2046
2047**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
2048
2049**系统能力:** SystemCapability.Account.OsAccount
2050
2051**参数:**
2052
2053| 参数名  | 类型   | 必填 | 说明         |
2054| ------- | ------ | ---- | ------------ |
2055| localId     | number | 是   |  要查询的系统账号ID |
2056| constraint     | string | 是   |  要查询的[约束](js-apis-osAccount.md#系统账号约束列表)名称 |
2057
2058**返回值:**
2059
2060| 类型                  | 说明                                                         |
2061| --------------------- | ------------------------------------------------------------ |
2062| Promise&lt;Array&lt;[ConstraintSourceTypeInfo](#constraintsourcetypeinfo9)&gt;&gt; | Promise对象,返回指定系统账号的指定[约束](js-apis-osAccount.md#系统账号约束列表)来源信息。 |
2063
2064**错误码:**
2065
2066| 错误码ID | 错误信息       |
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**示例:**
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
2096查询指定系统账号的类型,使用Promise异步回调。
2097
2098**系统接口:** 此接口为系统接口。
2099
2100**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
2101
2102**系统能力:** SystemCapability.Account.OsAccount
2103
2104**参数:**
2105
2106| 参数名  | 类型   | 必填 | 说明         |
2107| ------- | ------ | ---- | ------------ |
2108| localId     | number | 是   |  要查询的系统账号ID。 |
2109
2110**返回值:**
2111
2112| 类型                  | 说明                                                         |
2113| --------------------- | ------------------------------------------------------------ |
2114| Promise&lt;[OsAccountType](js-apis-osAccount.md#osaccounttype)&gt; | Promise对象,返回指定系统账号的类型。 |
2115
2116**错误码:**
2117
2118| 错误码ID | 错误信息       |
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**示例:**
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
2145用户认证类。
2146
2147**系统接口:** 此接口为系统接口。
2148
2149### constructor<sup>8+</sup>
2150
2151constructor()
2152
2153创建用户认证的实例。
2154
2155**系统接口:** 此接口为系统接口。
2156
2157**系统能力**:SystemCapability.Account.OsAccount
2158
2159**错误码:**
2160
2161| 错误码ID | 错误信息       |
2162| -------- | ------------- |
2163| 202 | Not system application.|
2164
2165**示例:**
2166  ```ts
2167  let userAuth = new osAccount.UserAuth();
2168  ```
2169
2170### getVersion<sup>8+</sup>
2171
2172getVersion(): number;
2173
2174返回版本信息。
2175
2176**系统接口:** 此接口为系统接口。
2177
2178**系统能力:** SystemCapability.Account.OsAccount
2179
2180**返回值:**
2181
2182| 类型   | 说明         |
2183| :----- | :----------- |
2184| number | 返回版本信息。|
2185
2186**错误码:**
2187
2188| 错误码ID | 错误信息       |
2189| -------- | ------------- |
2190| 202 | Not system application.|
2191
2192**示例:**
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
2203获取指定认证类型和认证可信等级的认证能力的可用状态。
2204
2205**系统接口:** 此接口为系统接口。
2206
2207**系统能力:** SystemCapability.Account.OsAccount
2208
2209**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2210
2211**参数:**
2212
2213| 参数名           | 类型                               | 必填 | 说明                       |
2214| --------------- | -----------------------------------| ---- | ------------------------- |
2215| authType        | [AuthType](#authtype8)             | 是   | 认证类型。     |
2216| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8) | 是   | 认证的可信等级。 |
2217
2218**返回值:**
2219
2220| 类型   | 说明                           |
2221| ------ | ----------------------------- |
2222| number | 返回认证能力的可用状态。 |
2223
2224**错误码:**
2225
2226| 错误码ID | 错误信息                     |
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**示例:**
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
2251基于指定的请求信息获取属性。使用callback异步回调。
2252
2253**系统接口:** 此接口为系统接口。
2254
2255**系统能力:** SystemCapability.Account.OsAccount
2256
2257**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2258
2259**参数:**
2260
2261| 参数名    | 类型                                                                    | 必填 | 说明                                |
2262| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------ |
2263| request  | [GetPropertyRequest](#getpropertyrequest8)                  | 是   | 请求信息,包括认证类型和属性类型列表。 |
2264| callback | AsyncCallback&lt;[ExecutorProperty](#executorproperty8)&gt; | 是   | 回调函数。如果获取成功,err为null,data为执行器属性信息;否则为错误对象。|
2265
2266**错误码:**
2267
2268| 错误码ID | 错误信息                     |
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**示例:**
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
2304基于指定的请求信息获取属性。使用Promise异步回调。
2305
2306**系统接口:** 此接口为系统接口。
2307
2308**系统能力:** SystemCapability.Account.OsAccount
2309
2310**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2311
2312**参数:**
2313
2314| 参数名    | 类型                                                   | 必填 | 说明                                |
2315| -------- | ------------------------------------------------------ | ---- | ---------------------------------- |
2316| request  | [GetPropertyRequest](#getpropertyrequest8) | 是   | 请求信息,包括认证类型和属性类型列表。 |
2317
2318**返回值:**
2319
2320| 类型                                                              | 说明                                                 |
2321| :---------------------------------------------------------------- | :-------------------------------------------------- |
2322| Promise&lt;[ExecutorProperty](#executorproperty8)&gt; | Promise对象,返回执行者属性信息。 |
2323
2324**错误码:**
2325
2326| 错误码ID | 错误信息                     |
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**示例:**
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
2363设置可用于初始化算法的属性。使用callback异步回调。
2364
2365**系统接口:** 此接口为系统接口。
2366
2367**系统能力:** SystemCapability.Account.OsAccount
2368
2369**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2370
2371**参数:**
2372
2373| 参数名    | 类型                                                  | 必填 | 说明                                                                    |
2374| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- |
2375| request  | [SetPropertyRequest](#setpropertyrequest8)| 是   | 请求信息,包括认证类型和要设置的密钥值。                                   |
2376| callback | AsyncCallback&lt;void&gt;                           | 是   | 回调函数。如果设置成功,err为null,否则为错误对象。 |
2377
2378**错误码:**
2379
2380| 错误码ID | 错误信息                     |
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**示例:**
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
2414设置可用于初始化算法的属性。使用Promise异步回调。
2415
2416**系统接口:** 此接口为系统接口。
2417
2418**系统能力:** SystemCapability.Account.OsAccount
2419
2420**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2421
2422**参数:**
2423
2424| 参数名    | 类型                                       | 必填 | 说明                                      |
2425| -------- | ------------------------------------------ | ---- | ---------------------------------------- |
2426| request  | [SetPropertyRequest](#setpropertyrequest8) | 是   | 请求信息,包括身份验证类型和要设置的密钥值。 |
2427
2428**返回值:**
2429
2430| 类型                  | 说明                                                           |
2431| :-------------------- | :------------------------------------------------------------ |
2432| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
2433
2434**错误码:**
2435
2436| 错误码ID | 错误信息                     |
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**示例:**
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
2468准备远端认证。使用Promise异步回调。
2469
2470**系统接口:** 此接口为系统接口。
2471
2472**系统能力:** SystemCapability.Account.OsAccount
2473
2474**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2475
2476**参数:**
2477
2478| 参数名            | 类型   | 必填 | 说明             |
2479| --------         | ------ | ---- | --------------- |
2480| remoteNetworkId  | string | 是   | 远端网络Id。  |
2481
2482**返回值:**
2483
2484| 类型                  | 说明                                                           |
2485| :-------------------- | :------------------------------------------------------------ |
2486| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
2487
2488**错误码:**
2489
2490| 错误码ID | 错误信息                     |
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**示例:**
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
2525认证当前用户。使用callback异步回调。
2526
2527**系统接口:** 此接口为系统接口。
2528
2529**系统能力:** SystemCapability.Account.OsAccount
2530
2531**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2532
2533**参数:**
2534
2535| 参数名           | 类型                                     | 必填 | 说明                                |
2536| --------------- | ---------------------------------------- | --- | ------------------------------------ |
2537| challenge       | Uint8Array                               | 是  | 指示挑战值,挑战值为一个随机数,用于提升安全性。|
2538| authType        | [AuthType](#authtype8)                   | 是  | 指示认证类型。                        |
2539| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8)       | 是  | 指示认证结果的信任级别。               |
2540| callback        | [IUserAuthCallback](#iuserauthcallback8) | 是  | 回调对象,返回认证结果。  |
2541
2542**返回值:**
2543
2544| 类型        | 说明               |
2545| ---------- | ------------------ |
2546| Uint8Array | 返回取消的上下文ID。 |
2547
2548**错误码:**
2549
2550| 错误码ID | 错误信息          |
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**示例:**
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
2589基于指定的挑战值、认证类型(如口令、人脸、指纹等)、认证可信等级以及可选参数(如账号标识、认证意图等)进行身份认证。使用callback异步回调。
2590
2591**系统接口:** 此接口为系统接口。
2592
2593**系统能力:** SystemCapability.Account.OsAccount
2594
2595**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2596
2597**参数:**
2598
2599| 参数名           | 类型                                     | 必填 | 说明                                |
2600| --------------- | ---------------------------------------- | --- | ------------------------------------ |
2601| challenge       | Uint8Array                               | 是  | 指示挑战值,挑战值为一个随机数,用于防止重放攻击,提升安全性。|
2602| authType        | [AuthType](#authtype8)                   | 是  | 指示认证类型。                        |
2603| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8)       | 是  | 指示认证结果的信任级别。               |
2604| options         | [AuthOptions](#authoptions12) | 是 | 指示认证用户的可选参数集合。 |
2605| callback        | [IUserAuthCallback](#iuserauthcallback8) | 是  | 回调对象,返回认证结果。  |
2606
2607**返回值:**
2608
2609| 类型        | 说明               |
2610| ---------- | ------------------ |
2611| Uint8Array | 返回取消的上下文ID。 |
2612
2613**错误码:**
2614
2615| 错误码ID | 错误信息          |
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**示例:**
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
2658认证指定用户。使用callback异步回调。
2659
2660**系统接口:** 此接口为系统接口。
2661
2662**系统能力:** SystemCapability.Account.OsAccount
2663
2664**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2665
2666**参数:**
2667
2668| 参数名           | 类型                                                 | 必填 | 说明                                |
2669| --------------- | ---------------------------------------------------- | --- | ------------------------------------ |
2670| userId          | number                                               | 是  | 指示用户身份。                        |
2671| challenge       | Uint8Array                                           | 是  | 指示挑战值,挑战值为一个随机数,用于提升安全性。                          |
2672| authType        | [AuthType](#authtype8)                   | 是  | 指示认证类型。                        |
2673| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8)       | 是  | 指示认证结果的信任级别。               |
2674| callback        | [IUserAuthCallback](#iuserauthcallback8) | 是  | 回调对象,返回认证结果。  |
2675
2676**返回值:**
2677
2678| 类型        | 说明               |
2679| ---------- | ------------------ |
2680| Uint8Array | 返回取消的上下文ID。 |
2681
2682**错误码:**
2683
2684| 错误码ID | 错误信息          |
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**示例:**
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
2725取消指定的认证操作。
2726
2727**系统接口:** 此接口为系统接口。
2728
2729**系统能力:** SystemCapability.Account.OsAccount
2730
2731**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2732
2733**参数:**
2734
2735| 参数名    | 类型       | 必填  | 说明                                        |
2736| ----------| ---------- | ---- | ------------------------------------------ |
2737| contextId | Uint8Array | 是   | 指示身份验证上下文ID,此ID动态生成没有具体值。 |
2738
2739**错误码:**
2740
2741| 错误码ID | 错误信息            |
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**示例:**
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
2769PIN码认证基类。
2770
2771**系统接口:** 此接口为系统接口。
2772
2773### constructor<sup>8+</sup>
2774
2775constructor()
2776
2777创建PIN码认证的实例。
2778
2779**系统接口:** 此接口为系统接口。
2780
2781**系统能力**:SystemCapability.Account.OsAccount
2782
2783**错误码:**
2784
2785| 错误码ID | 错误信息       |
2786| -------- | ------------- |
2787| 202 | Not system application.|
2788
2789**示例:**
2790  ```ts
2791  let pinAuth: osAccount.PINAuth = new osAccount.PINAuth();
2792  ```
2793
2794### registerInputer<sup>8+</sup>
2795
2796registerInputer(inputer: IInputer): void
2797
2798注册PIN码输入器。
2799
2800**系统接口:** 此接口为系统接口。
2801
2802**系统能力:** SystemCapability.Account.OsAccount
2803
2804**需要权限:** ohos.permission.ACCESS_PIN_AUTH
2805
2806**参数:**
2807
2808| 参数名    | 类型                     | 必填 | 说明                      |
2809| ----------| ----------------------- | --- | -------------------------- |
2810| inputer   | [IInputer](#iinputer8)  | 是  | PIN码输入器,用于获取PIN码。 |
2811
2812**错误码:**
2813
2814| 错误码ID | 错误信息                     |
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**示例:**
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
2843解注册PIN码输入器。
2844
2845**系统接口:** 此接口为系统接口。
2846
2847**系统能力:** SystemCapability.Account.OsAccount
2848
2849**需要权限:** ohos.permission.ACCESS_PIN_AUTH
2850
2851**错误码:**
2852
2853| 错误码ID | 错误信息                     |
2854| -------- | --------------------------- |
2855| 201 | Permission denied.|
2856| 202 | Not system application.|
2857
2858**示例:**
2859  ```ts
2860  let pinAuth: osAccount.PINAuth = new osAccount.PINAuth();
2861  pinAuth.unregisterInputer();
2862  ```
2863
2864## InputerManager <sup>9+</sup>
2865
2866凭据输入管理器。
2867
2868### registerInputer<sup>9+</sup>
2869
2870static registerInputer(authType: AuthType, inputer: IInputer): void
2871
2872注册凭据输入器。
2873
2874**系统接口:** 此接口为系统接口。
2875
2876**系统能力:** SystemCapability.Account.OsAccount
2877
2878**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNALohos.permission.MANAGE_USER_IDM
2879
2880**参数:**
2881
2882| 参数名    | 类型                     | 必填 | 说明                      |
2883| ----------| ----------------------- | --- | -------------------------- |
2884| authType   | [AuthType](#authtype8)  | 是  | 认证类型。 |
2885| inputer   | [IInputer](#iinputer8)  | 是  | 凭据输入器,用于获取凭据。 |
2886
2887**错误码:**
2888
2889| 错误码ID | 错误信息                     |
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**示例:**
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
2919解注册凭据输入器。
2920
2921**系统接口:** 此接口为系统接口。
2922
2923**系统能力:** SystemCapability.Account.OsAccount
2924
2925**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNALohos.permission.MANAGE_USER_IDM
2926
2927**参数:**
2928
2929| 参数名    | 类型                     | 必填 | 说明                      |
2930| ----------| ----------------------- | --- | -------------------------- |
2931| authType   | [AuthType](#authtype8)  | 是  | 认证类型。 |
2932
2933**错误码:**
2934
2935| 错误码ID | 错误信息                     |
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**示例:**
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
2955域插件,提供域账号认证功能。
2956
2957**系统接口:** 此接口为系统接口。
2958
2959### auth<sup>9+</sup>
2960
2961auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUserAuthCallback): void
2962
2963认证指定的域账号。
2964
2965**系统接口:** 此接口为系统接口。
2966
2967**系统能力:** SystemCapability.Account.OsAccount
2968
2969**参数:**
2970
2971| 参数名      | 类型                                    | 必填 | 说明             |
2972| ---------- | --------------------------------------- | ---- | --------------- |
2973| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
2974| credential   | Uint8Array  | 是   | 指示域账号的凭据。|
2975| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
2976
2977**示例:**
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
3028弹窗认证指定的域账号。
3029
3030**系统接口:** 此接口为系统接口。
3031
3032**系统能力:** SystemCapability.Account.OsAccount
3033
3034**参数:**
3035
3036| 参数名      | 类型                                    | 必填 | 说明             |
3037| ---------- | --------------------------------------- | ---- | --------------- |
3038| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3039| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
3040
3041**示例:**
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
3078使用授权令牌认证指定的域账号。
3079
3080**系统接口:** 此接口为系统接口。
3081
3082**系统能力:** SystemCapability.Account.OsAccount
3083
3084**参数:**
3085
3086| 参数名      | 类型                                    | 必填 | 说明             |
3087| ---------- | --------------------------------------- | ---- | --------------- |
3088| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3089| token   | Uint8Array  | 是   | 指示PIN码或生物识别认证成功时生成的授权令牌。|
3090| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
3091
3092**示例:**
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
3129查询指定域账号的信息。
3130
3131**系统接口:** 此接口为系统接口。
3132
3133**系统能力:** SystemCapability.Account.OsAccount
3134
3135**参数:**
3136
3137| 参数名      | 类型                                    | 必填 | 说明             |
3138| ---------- | --------------------------------------- | ---- | --------------- |
3139| options   | [GetDomainAccountInfoPluginOptions](#getdomainaccountinfopluginoptions10)  | 是   | 指示域账号信息。|
3140| callback   | AsyncCallback&lt;[DomainAccountInfo](#domainaccountinfo8)&gt; | 是   | 指示查询结果回调。|
3141
3142**示例:**
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
3184查询指定域账号的认证状态信息。
3185
3186**系统接口:** 此接口为系统接口。
3187
3188**系统能力:** SystemCapability.Account.OsAccount
3189
3190**参数:**
3191
3192| 参数名      | 类型                                    | 必填 | 说明             |
3193| ---------- | --------------------------------------- | ---- | --------------- |
3194| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3195| callback   | AsyncCallback&lt;[AuthStatusInfo](#authstatusinfo10)&gt; | 是   | 指示查询结果回调。|
3196
3197**示例:**
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
3236绑定指定的域账号。
3237
3238**系统接口:** 此接口为系统接口。
3239
3240**系统能力:** SystemCapability.Account.OsAccount
3241
3242**参数:**
3243
3244| 参数名      | 类型                                    | 必填 | 说明             |
3245| ---------- | --------------------------------------- | ---- | --------------- |
3246| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3247| callback   | AsyncCallback&lt;void&gt; | 是   | 指示绑定结果回调。|
3248
3249**示例:**
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
3286解绑指定的域账号。
3287
3288**系统接口:** 此接口为系统接口。
3289
3290**系统能力:** SystemCapability.Account.OsAccount
3291
3292**参数:**
3293
3294| 参数名      | 类型                                    | 必填 | 说明             |
3295| ---------- | --------------------------------------- | ---- | --------------- |
3296| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3297| callback   | AsyncCallback&lt;void&gt; | 是   | 指示绑定结果回调。|
3298
3299**示例:**
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
3336检查指定的域账号令牌是否有效。
3337
3338**系统接口:** 此接口为系统接口。
3339
3340**系统能力:** SystemCapability.Account.OsAccount
3341
3342**参数:**
3343
3344| 参数名      | 类型                                    | 必填 | 说明             |
3345| ---------- | --------------------------------------- | ---- | --------------- |
3346| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3347| token | Uint8Array | 是 | 指示域账号令牌。 |
3348| callback   | AsyncCallback&lt;boolean&gt; | 是   | 指示检查结果回调。|
3349
3350**示例:**
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
3387根据指定的选项获取域访问令牌。
3388
3389**系统接口:** 此接口为系统接口。
3390
3391**系统能力:** SystemCapability.Account.OsAccount
3392
3393**参数:**
3394
3395| 参数名      | 类型                                    | 必填 | 说明             |
3396| ---------- | --------------------------------------- | ---- | --------------- |
3397| options | [GetDomainAccessTokenOptions](#getdomainaccesstokenoptions10)  | 是   | 指示获取域访问令牌的选项。|
3398| callback   | AsyncCallback&lt;Uint8Array&gt; | 是   | 指示结果回调。|
3399
3400**示例:**
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>
3435域账号管理器类。
3436
3437### registerPlugin<sup>9+</sup>
3438
3439static registerPlugin(plugin: DomainPlugin): void
3440
3441注册域插件。
3442
3443**系统接口:** 此接口为系统接口。
3444
3445**系统能力:** SystemCapability.Account.OsAccount
3446
3447**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3448
3449**参数:**
3450
3451| 参数名    | 类型                     | 必填 | 说明                      |
3452| ----------| ----------------------- | --- | -------------------------- |
3453| plugin   | [DomainPlugin](#domainplugin9)  | 是  | 指示域插件。 |
3454
3455**错误码:**
3456
3457| 错误码ID | 错误信息                     |
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**示例:**
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
3497注销域插件。
3498
3499**系统接口:** 此接口为系统接口。
3500
3501**系统能力:** SystemCapability.Account.OsAccount
3502
3503**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3504
3505**错误码:**
3506
3507| 错误码ID | 错误信息                     |
3508| -------- | --------------------------- |
3509| 201 | Permission denied.|
3510| 202 | Not system application.|
3511
3512**示例:**
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
3526认证指定的域账号。
3527
3528**系统接口:** 此接口为系统接口。
3529
3530**系统能力:** SystemCapability.Account.OsAccount
3531
3532**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
3533
3534**参数:**
3535
3536| 参数名      | 类型                                    | 必填 | 说明             |
3537| ---------- | --------------------------------------- | ---- | --------------- |
3538| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3539| credential   | Uint8Array  | 是   | 指示域账号的凭据。|
3540| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
3541
3542**错误码:**
3543
3544| 错误码ID | 错误信息                     |
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**示例:**
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
3585弹框认证指定的域账号。
3586
3587**系统接口:** 此接口为系统接口。
3588
3589**系统能力:** SystemCapability.Account.OsAccount
3590
3591**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
3592
3593从API version 11开始无需申请权限,建议升级SDK版本。
3594
3595**参数:**
3596
3597| 参数名      | 类型                                    | 必填 | 说明             |
3598| ---------- | --------------------------------------- | ---- | --------------- |
3599| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
3600
3601**错误码:**
3602
3603| 错误码ID | 错误信息                     |
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**示例:**
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
3638弹框认证指定的域账号。
3639
3640**系统接口:** 此接口为系统接口。
3641
3642**系统能力:** SystemCapability.Account.OsAccount
3643
3644**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
3645
3646从API version 11开始无需申请权限,建议升级SDK版本。
3647
3648**参数:**
3649
3650| 参数名      | 类型                                    | 必填 | 说明             |
3651| ---------- | --------------------------------------- | ---- | --------------- |
3652| localId   | number  | 是   | 指示绑定域账号的系统账号的本地标识。|
3653| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
3654
3655**错误码:**
3656
3657| 错误码ID | 错误信息                     |
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**示例:**
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
3693检查是否存在指定的域账号。
3694
3695**系统接口:** 此接口为系统接口。
3696
3697**系统能力:** SystemCapability.Account.OsAccount
3698
3699**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3700
3701**参数:**
3702
3703| 参数名      | 类型                                    | 必填 | 说明             |
3704| ---------- | --------------------------------------- | ---- | --------------- |
3705| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3706| callback   | AsyncCallback&lt;boolean&gt;  | 是   | 指示检查结果回调。|
3707
3708**错误码:**
3709
3710| 错误码ID | 错误信息                     |
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**示例:**
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
3745检查是否存在指定的域账号。
3746
3747**系统接口:** 此接口为系统接口。
3748
3749**系统能力:** SystemCapability.Account.OsAccount
3750
3751**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3752
3753**参数:**
3754
3755| 参数名      | 类型                                    | 必填 | 说明             |
3756| ---------- | --------------------------------------- | ---- | --------------- |
3757| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3758
3759**返回值:**
3760
3761| 类型                      | 说明                     |
3762| :------------------------ | ----------------------- |
3763| Promise&lt;boolean&gt; | Promise对象,返回指定的域账号是否存在。 |
3764
3765**错误码:**
3766
3767| 错误码ID | 错误信息                     |
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**示例:**
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
3800更新指定域账号的令牌,空令牌表示目标域账号的令牌失效。使用callback异步回调。
3801
3802**系统接口:** 此接口为系统接口。
3803
3804**系统能力:** SystemCapability.Account.OsAccount
3805
3806**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3807
3808**参数:**
3809
3810| 参数名      | 类型                                    | 必填 | 说明             |
3811| ---------- | --------------------------------------- | ---- | --------------- |
3812| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3813| token | Uint8Array  | 是   | 指示域账号的令牌。|
3814| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。如果更新成功,err为null,否则为错误对象。|
3815
3816**错误码:**
3817
3818| 错误码ID | 错误信息                     |
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**示例:**
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
3853更新指定域账号的令牌,空令牌表示目标域账号的令牌失效。使用Promise异步回调。
3854
3855**系统接口:** 此接口为系统接口。
3856
3857**系统能力:** SystemCapability.Account.OsAccount
3858
3859**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3860
3861**参数:**
3862
3863| 参数名      | 类型                                    | 必填 | 说明             |
3864| ---------- | --------------------------------------- | ---- | --------------- |
3865| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
3866| token | Uint8Array  | 是   | 指示域账号的令牌。|
3867
3868**返回值:**
3869
3870| 类型                      | 说明                     |
3871| :------------------------ | ----------------------- |
3872| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
3873
3874**错误码:**
3875
3876| 错误码ID | 错误信息                     |
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**示例:**
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
3909修改指定域账号信息。使用Promise异步回调。
3910
3911**系统接口:** 此接口为系统接口。
3912
3913**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3914
3915**系统能力:** SystemCapability.Account.OsAccount
3916
3917**参数:**
3918
3919| 参数名      | 类型                                    | 必填 | 说明             |
3920| ---------- | --------------------------------------- | ---- | --------------- |
3921| oldAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示旧域账号信息。|
3922| newAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示新域账号信息。|
3923
3924**错误码:**
3925
3926| 错误码ID | 错误信息                     |
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**示例:**
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
3959查询指定的域账号信息,callback方式。
3960
3961**系统接口:** 此接口为系统接口。
3962
3963**系统能力:** SystemCapability.Account.OsAccount
3964
3965**需要权限:** ohos.permission.GET_DOMAIN_ACCOUNTS
3966
3967**参数:**
3968
3969| 参数名      | 类型                                    | 必填 | 说明             |
3970| ---------- | --------------------------------------- | ---- | --------------- |
3971| options   | [GetDomainAccountInfoOptions](#getdomainaccountinfooptions10)  | 是   | 指示域账号信息。|
3972| callback   | AsyncCallback&lt;DomainAccountInfo&gt;  | 是   | 指示查询结果回调。|
3973
3974**错误码:**
3975
3976| 错误码ID | 错误信息                     |
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**示例:**
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
4012查询指定的域账号信息,promise方式。
4013
4014**系统接口:** 此接口为系统接口。
4015
4016**系统能力:** SystemCapability.Account.OsAccount
4017
4018**需要权限:** ohos.permission.GET_DOMAIN_ACCOUNTS
4019
4020**参数:**
4021
4022| 参数名      | 类型                                    | 必填 | 说明             |
4023| ---------- | --------------------------------------- | ---- | --------------- |
4024| options   | [GetDomainAccountInfoOptions](#getdomainaccountinfooptions10)  | 是   | 指示域账号信息。|
4025
4026**返回值:**
4027
4028| 类型                      | 说明                     |
4029| :------------------------ | ----------------------- |
4030| Promise&lt;DomainAccountInfo&gt; | Promise对象,返回指定的域账号信息。 |
4031
4032**错误码:**
4033
4034| 错误码ID | 错误信息                     |
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**示例:**
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
4068获取当前域账号的业务访问令牌,使用callback异步回调。
4069
4070**系统接口:** 此接口为系统接口。
4071
4072**系统能力:** SystemCapability.Account.OsAccount
4073
4074**参数:**
4075
4076| 参数名      | 类型                                    | 必填 | 说明             |
4077| ---------- | --------------------------------------- | ---- | --------------- |
4078| businessParams | Record<string, Object>  | 是   | 指示业务参数,具体格式取决于域插件的实现要求。|
4079| callback | AsyncCallback&lt;Uint8Array&gt;  | 是   | 指示结果回调。如果获取成功,err返回null,否则为错误对象。|
4080
4081**错误码:**
4082
4083| 错误码ID | 错误信息                     |
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**示例:**
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
4120查询当前域账号的业务访问令牌,使用promise异步回调。
4121
4122**系统接口:** 此接口为系统接口。
4123
4124**系统能力:** SystemCapability.Account.OsAccount
4125
4126**参数:**
4127
4128| 参数名      | 类型                                    | 必填 | 说明             |
4129| ---------- | --------------------------------------- | ---- | --------------- |
4130| businessParams | Record<string, Object> | 是   | 指示业务参数,具体格式取决于域插件的实现要求。|
4131
4132**返回值:**
4133
4134| 类型                      | 说明                     |
4135| :------------------------ | ----------------------- |
4136| Promise&lt;Uint8Array&gt; | Promise对象,返回业务访问令牌。 |
4137
4138**错误码:**
4139
4140| 错误码ID | 错误信息                     |
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**示例:**
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
4175判断指定域账号是否登录超期。使用Promise异步回调。
4176
4177**系统接口:** 此接口为系统接口。
4178
4179**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
4180
4181**系统能力:** SystemCapability.Account.OsAccount
4182
4183**参数:**
4184
4185| 参数名      | 类型                                    | 必填 | 说明             |
4186| ---------- | --------------------------------------- | ---- | --------------- |
4187| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域账号信息。|
4188
4189**返回值:**
4190
4191| 类型                      | 说明                     |
4192| :------------------------ | ----------------------- |
4193| Promise&lt;boolean&gt; | Promise对象,返回指定的域账号是否登录超期。 |
4194
4195**错误码:**
4196
4197| 错误码ID | 错误信息                     |
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**示例:**
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
4224域服务器配置。
4225
4226**系统接口:** 此接口为系统接口。
4227
4228**系统能力:** SystemCapability.Account.OsAccount
4229
4230| 名称      | 类型   | 必填 | 说明       |
4231| ----------- | ------ | ---- | ---------- |
4232| parameters | Record<string, Object> | 是   | 服务器配置参数。 |
4233| id | string | 是   | 服务器配置标识。|
4234| domain | string | 是 | 服务器所属的域。 |
4235
4236## DomainServerConfigManager<sup>12+</sup>
4237
4238域服务器配置管理类。
4239
4240### addServerConfig<sup>12+</sup>
4241
4242static addServerConfig(parameters: Record&lt;string, Object&gt;): Promise&lt;DomainServerConfig&gt;
4243
4244添加域服务器配置。使用Promise异步回调。
4245
4246**系统接口:** 此接口为系统接口。
4247
4248**系统能力:** SystemCapability.Account.OsAccount
4249
4250**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
4251
4252**参数:**
4253
4254| 参数名    | 类型                     | 必填 | 说明                      |
4255| ----------| ----------------------- | --- | -------------------------- |
4256| parameters   | Record<string, Object>  | 是  | 指示域服务器配置参数。 |
4257
4258**返回值:**
4259
4260| 类型                      | 说明                     |
4261| :------------------------ | ----------------------- |
4262| Promise&lt;[DomainServerConfig](#domainserverconfig12)&gt; | Promise对象,返回新添加的域服务器配置。 |
4263
4264**错误码:**
4265
4266| 错误码ID | 错误信息                     |
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**示例:**
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
4295删除域服务器配置。使用Promise异步回调。
4296
4297**系统接口:** 此接口为系统接口。
4298
4299**系统能力:** SystemCapability.Account.OsAccount
4300
4301**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
4302
4303**参数:**
4304
4305| 参数名    | 类型                     | 必填 | 说明                      |
4306| ----------| ----------------------- | --- | -------------------------- |
4307| configId   | string  | 是  | 指示服务器配置标识。 |
4308
4309**返回值:**
4310
4311| 类型                      | 说明                     |
4312| :------------------------ | ----------------------- |
4313| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
4314
4315**错误码:**
4316
4317| 错误码ID | 错误信息                     |
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**示例:**
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
4347获取目标域账号的服务器配置。使用Promise异步回调。
4348
4349**系统接口:** 此接口为系统接口。
4350
4351**系统能力:** SystemCapability.Account.OsAccount
4352
4353**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
4354
4355**参数:**
4356
4357| 参数名    | 类型                     | 必填 | 说明                      |
4358| ----------| ----------------------- | --- | -------------------------- |
4359| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是  | 指示目标域账号信息。 |
4360
4361**返回值:**
4362
4363| 类型                      | 说明                     |
4364| :------------------------ | ----------------------- |
4365| Promise&lt;[DomainServerConfig](#domainserverconfig12)&gt; | Promise对象,返回目标账号的域服务器配置。 |
4366
4367**错误码:**
4368
4369| 错误码ID | 错误信息                     |
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**示例:**
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
4396获取用户身份管理类。
4397
4398**系统接口:** 此接口为系统接口。
4399
4400### constructor<sup>8+</sup>
4401
4402constructor()
4403
4404用户身份管理类的默认构造函数。
4405
4406**系统接口:** 此接口为系统接口。
4407
4408**系统能力**:SystemCapability.Account.OsAccount
4409
4410**错误码:**
4411
4412| 错误码ID | 错误信息                     |
4413| -------- | --------------------------- |
4414| 202 | Not system application.|
4415
4416**示例:**
4417  ```ts
4418  let userIDM = new osAccount.UserIdentityManager();
4419  ```
4420
4421### openSession<sup>8+</sup>
4422
4423openSession(callback: AsyncCallback&lt;Uint8Array&gt;): void
4424
4425打开会话,获取挑战值。使用callback异步回调。
4426
4427**系统接口:** 此接口为系统接口。
4428
4429**系统能力:** SystemCapability.Account.OsAccount
4430
4431**需要权限:** ohos.permission.MANAGE_USER_IDM
4432
4433**参数:**
4434
4435| 参数名    | 类型                             | 必填 | 说明                                                            |
4436| -------- | -------------------------------- | ---- | -------------------------------------------------------------- |
4437| callback | AsyncCallback&lt;Uint8Array&gt;  | 是   | 回调函数。如果打开会话成功,err为null,data为挑战值;否则为错误对象。|
4438
4439**错误码:**
4440
4441| 错误码ID | 错误信息                     |
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**示例:**
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
4466打开会话,获取挑战值(用于判断后续的身份认证场景是否处于该会话下,防止重放攻击)。使用Promise异步回调。
4467
4468**系统接口:** 此接口为系统接口。
4469
4470**系统能力:** SystemCapability.Account.OsAccount
4471
4472**需要权限:** ohos.permission.MANAGE_USER_IDM
4473
4474**参数:**
4475
4476| 参数名     | 类型    | 必填 | 说明        |
4477| --------- | ------- | ---- | ----------- |
4478| accountId<sup>12+</sup> | number  | 否   | 系统账号标识,默认为空。 |
4479
4480**返回值:**
4481
4482| 类型                      | 说明                     |
4483| :------------------------ | ----------------------- |
4484| Promise&lt;Uint8Array&gt; | Promise对象,返回挑战值。 |
4485
4486**错误码:**
4487
4488| 错误码ID | 错误信息                     |
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**示例:**
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
4517添加凭据,添加用户凭据信息,传入凭据添加方法和凭据信息(凭据类型,子类,如果添加用户的非密码凭据,则传入密码身份验证令牌),并获取结果/获取信息。
4518
4519**系统接口:** 此接口为系统接口。
4520
4521**系统能力:** SystemCapability.Account.OsAccount
4522
4523**需要权限:** ohos.permission.MANAGE_USER_IDM
4524
4525**参数:**
4526
4527| 参数名           | 类型                                 | 必填 | 说明                        |
4528| --------------- | ------------------------------------ | --- | ---------------------------- |
4529| credentialInfo  | [CredentialInfo](#credentialinfo8)   | 是  | 指示凭据信息。                |
4530| callback        | [IIdmCallback](#iidmcallback8)       | 是  | 回调对象,返回添加凭据的结果。  |
4531
4532**错误码:**
4533
4534| 错误码ID | 错误信息                     |
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**示例:**
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
4584更新凭据。使用callback异步回调。
4585
4586**系统接口:** 此接口为系统接口。
4587
4588**系统能力:** SystemCapability.Account.OsAccount
4589
4590**需要权限:** ohos.permission.MANAGE_USER_IDM
4591
4592**参数:**
4593
4594| 参数名           | 类型                                  | 必填 | 说明                     |
4595| --------------- | ------------------------------------- | --- | ------------------------- |
4596| credentialInfo  | [CredentialInfo](#credentialinfo8)    | 是  | 指示凭据信息。             |
4597| callback        | [IIdmCallback](#iidmcallback8)        | 是  | 回调对象,返回更新凭据的结果。 |
4598
4599**错误码:**
4600
4601| 错误码ID | 错误信息                     |
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**示例:**
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
4661关闭会话,结束IDM操作。
4662
4663**系统接口:** 此接口为系统接口。
4664
4665**系统能力:** SystemCapability.Account.OsAccount
4666
4667**需要权限:** ohos.permission.MANAGE_USER_IDM
4668
4669**参数:**
4670
4671| 参数名     | 类型    | 必填 | 说明        |
4672| --------- | ------- | ---- | ----------- |
4673| accountId<sup>12+</sup> | number  | 否   | 系统账号标识,默认为空。 |
4674
4675**错误码:**
4676
4677| 错误码ID | 错误信息                     |
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**示例:**
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
4697根据挑战值取消条目。
4698
4699**系统接口:** 此接口为系统接口。
4700
4701**系统能力:** SystemCapability.Account.OsAccount
4702
4703**需要权限:** ohos.permission.MANAGE_USER_IDM
4704
4705**参数:**
4706
4707| 参数名    | 类型        | 必填 | 说明   |
4708| -------- | ----------- | ---- | ----- |
4709| challenge | Uint8Array | 是   | 挑战值。 |
4710
4711**错误码:**
4712
4713| 错误码ID | 错误信息            |
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**示例:**
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
4736删除具有身份验证令牌的用户,使用callback方式异步返回结果。
4737
4738**系统接口:** 此接口为系统接口。
4739
4740**系统能力:** SystemCapability.Account.OsAccount
4741
4742**需要权限:** ohos.permission.MANAGE_USER_IDM
4743
4744**参数:**
4745
4746| 参数名    | 类型                           | 必填 | 说明                      |
4747| -------- | ------------------------------ | --- | ------------------------- |
4748| token    | Uint8Array                     | 是  | 身份验证令牌。             |
4749| callback | [IIdmCallback](#iidmcallback8) | 是  | 回调对象,返回删除用户的结果。|
4750
4751**错误码:**
4752
4753| 错误码ID | 错误信息        |
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**示例:**
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
4781删除用户凭据信息。
4782
4783**系统接口:** 此接口为系统接口。
4784
4785**系统能力:** SystemCapability.Account.OsAccount
4786
4787**需要权限:** ohos.permission.MANAGE_USER_IDM
4788
4789**参数:**
4790
4791| 参数名           | 类型                                            | 必填 | 说明                      |
4792| --------------- | ----------------------------------- | --- | ---------------------------|
4793| credentialId    | Uint8Array                          | 是  | 凭证索引。                  |
4794| token           | Uint8Array                          | 是  | 身份验证令牌。               |
4795| callback        | [IIdmCallback](#iidmcallback8)      | 是  | 回调对象,返回删除凭据的结果。 |
4796
4797**错误码:**
4798
4799| 错误码ID | 错误信息             |
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**示例:**
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
4830获取认证信息。使用callback异步回调。
4831
4832**系统接口:** 此接口为系统接口。
4833
4834**系统能力:** SystemCapability.Account.OsAccount
4835
4836**需要权限:** ohos.permission.USE_USER_IDM
4837
4838**参数:**
4839
4840| 参数名    | 类型                                                                     | 必填 | 说明                                                 |
4841| -------- | ------------------------------------------------------------------------ | ---- | --------------------------------------------- |
4842| callback | AsyncCallback&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | 是   | 回调函数。如果成功,err为null,data为当前用户的所有已注册凭据信息;否则为错误对象。|
4843
4844**错误码:**
4845
4846| 错误码ID | 错误信息               |
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**示例:**
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
4872获取指定类型的认证信息。使用callback异步回调。
4873
4874**系统接口:** 此接口为系统接口。
4875
4876**系统能力:** SystemCapability.Account.OsAccount
4877
4878**需要权限:** ohos.permission.USE_USER_IDM
4879
4880**参数:**
4881
4882| 参数名    | 类型                                               | 必填 | 说明                                                |
4883| -------- | -------------------------------------------------- | ---- | -------------------------------------------------- |
4884| authType | [AuthType](#authtype8) | 是   | 认证类型。                                          |
4885| callback | AsyncCallback&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | 是   | 回调函数,如果获取成功,err为null,data为当前用户指定类型的所有已注册凭据信息;否则为错误对象。 |
4886
4887**错误码:**
4888
4889| 错误码ID | 错误信息               |
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**示例:**
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
4917获取认证信息。使用Promise异步回调。
4918
4919**系统接口:** 此接口为系统接口。
4920
4921**系统能力:** SystemCapability.Account.OsAccount
4922
4923**需要权限:** ohos.permission.USE_USER_IDM
4924
4925**参数:**
4926
4927| 参数名    | 类型                                | 必填 | 说明      |
4928| -------- | ----------------------------------- | ---- | -------- |
4929| authType | [AuthType](#authtype8)              | 否   | 认证类型,默认为空,表示查询所有认证类型的信息。|
4930
4931**返回值:**
4932
4933| 类型                                         | 说明                                                                     |
4934| :------------------------------------------- | :----------------------------------------------------------------------- |
4935| Promise&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Promise对象,返回当前用户指定类型的所有已注册凭据信息。|
4936
4937**错误码:**
4938
4939| 错误码ID | 错误信息               |
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**示例:**
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
4967依据提供的可选参数,获取认证信息。使用Promise异步回调。
4968
4969**系统接口:** 此接口为系统接口。
4970
4971**系统能力:** SystemCapability.Account.OsAccount
4972
4973**需要权限:** ohos.permission.USE_USER_IDM
4974
4975**参数:**
4976
4977| 参数名    | 类型                                | 必填 | 说明      |
4978| -------- | ----------------------------------- | ---- | -------- |
4979| options | [GetAuthInfoOptions](#getauthinfooptions12)          | 否   | 获取认证信息的可选参数集合。 |
4980
4981**返回值:**
4982
4983| 类型                                         | 说明                                                                     |
4984| :------------------------------------------- | :----------------------------------------------------------------------- |
4985| Promise&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Promise对象,返回当前用户指定类型的所有已注册凭据信息。|
4986
4987**错误码:**
4988
4989| 错误码ID | 错误信息               |
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**示例:**
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
5021基于凭据类型,以及可选的账号标识,获取已注册的凭据ID。使用Promise异步回调。
5022
5023**系统接口:** 此接口为系统接口。
5024
5025**系统能力:** SystemCapability.Account.OsAccount
5026
5027**需要权限:** ohos.permission.USE_USER_IDM
5028
5029**参数:**
5030
5031| 参数名     | 类型                   | 必填 | 说明      |
5032| --------  | ---------------------- | ---- | -------- |
5033| authType  | [AuthType](#authtype8) | 是   | 认证凭据类型 |
5034| accountId | number                 | 否   | 系统账号标识,默认为空。 |
5035
5036**返回值:**
5037
5038| 类型                       | 说明                                                                     |
5039| :------------------------ | :----------------------------------------------------------------------- |
5040| Promise&lt;Uint8Array&gt; | Promise对象,返回已注册的凭据ID。|
5041
5042**错误码:**
5043
5044| 错误码ID | 错误信息               |
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**示例:**
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
5074密码数据回调。
5075
5076**系统接口:** 此接口为系统接口。
5077
5078### onSetData<sup>8+</sup>
5079
5080onSetData: (authSubType: AuthSubType, data: Uint8Array) => void;
5081
5082**系统接口:** 此接口为系统接口。
5083
5084通知设置数据。
5085
5086**系统能力:** SystemCapability.Account.OsAccount
5087
5088**参数:**
5089
5090| 参数名      | 类型                                     | 必填 | 说明                                            |
5091| ---------- | ---------------------------------------- | ---- | ----------------------------------------------- |
5092| authSubType | [AuthSubType](#authsubtype8)             | 是   | 用于认证的凭据子类型。                            |
5093| data       | Uint8Array                               | 是   | 要设置的数据是凭据,用来在认证、添加、修改凭据操作。 |
5094
5095**错误码:**
5096
5097| 错误码ID | 错误信息               |
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**示例:**
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
5120凭据输入器回调。
5121
5122**系统接口:** 此接口为系统接口。
5123
5124### onGetData<sup>8+</sup>
5125
5126onGetData: (authSubType: AuthSubType, callback: IInputData, options: GetInputDataOptions) => void;
5127
5128通知调用者获取数据的回调函数。
5129
5130**系统接口:** 此接口为系统接口。
5131
5132**系统能力:** SystemCapability.Account.OsAccount
5133
5134**参数:**
5135
5136| 参数名      | 类型                                    | 必填 | 说明             |
5137| ---------- | --------------------------------------- | ---- | --------------- |
5138| authSubType | [AuthSubType](#authsubtype8) | 是 | 认证凭据子类型。 |
5139| callback   | [IInputData](#iinputdata8)  | 是   | 指示密码数据回调。|
5140| options | [GetInputDataOptions](#getinputdataoptions-12) | 是 | 回调函数的可选参数集合。 |
5141
5142**示例:**
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
5163表示用户认证回调类。
5164
5165**系统接口:** 此接口为系统接口。
5166
5167### onResult<sup>8+</sup>
5168
5169onResult: (result: number, extraInfo: AuthResult) => void;
5170
5171身份认证结果回调函数,返回结果码和认证结果信息。
5172
5173**系统接口:** 此接口为系统接口。
5174
5175**系统能力:** SystemCapability.Account.OsAccount
5176
5177**参数:**
5178
5179| 参数名     | 类型                                    | 必填 | 说明                 |
5180| --------- | --------------------------------------- | ---- | ------------------- |
5181| result    | number                                   | 是   | 表示身份认证结果代码。|
5182| extraInfo | [AuthResult](#authresult8)  | 是   | 表示不同情况下的具体信息,如果认证通过,则在extrainfo中返回认证令牌,如果身份验证失败,则在extrainfo中返回剩余的身份验证时间,如果身份验证执行器被锁定,冻结时间将在extrainfo中返回。|
5183
5184**示例:**
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
5198身份认证信息获取回调函数。
5199
5200**系统接口:** 此接口为系统接口。
5201
5202**系统能力:** SystemCapability.Account.OsAccount
5203
5204**参数:**
5205
5206| 参数名    | 类型     | 必填 | 说明                           |
5207| --------- | ------- | ---- | ----------------------------- |
5208| module    | number  | 是   | 指示用于身份验证的执行器类型。   |
5209| acquire   | number  | 是   | 指示不同身份验证执行器的tip代码。|
5210| extraInfo | Uint8Array     | 是   | 保留参数。                     |
5211
5212**示例:**
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
5229表示身份管理回调类。
5230
5231**系统接口:** 此接口为系统接口。
5232
5233### onResult<sup>8+</sup>
5234
5235onResult: (result: number, extraInfo: RequestResult) => void;
5236
5237身份管理操作结果回调函数,返回结果码和请求结果信息。
5238
5239**系统接口:** 此接口为系统接口。
5240
5241**系统能力:** SystemCapability.Account.OsAccount
5242
5243**参数:**
5244
5245| 参数名     | 类型                                    | 必填 | 说明                     |
5246| --------- | --------------------------------------- | ---- | ----------------------- |
5247| result    | number                                  | 是   | 表示身份认证结果代码。    |
5248| extraInfo | [RequestResult](#requestresult8)  | 是   | 针对不同情况传递具体信息。|
5249
5250**示例:**
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
5264身份管理信息获取回调函数。
5265
5266**系统接口:** 此接口为系统接口。
5267
5268**系统能力:** SystemCapability.Account.OsAccount
5269
5270**参数:**
5271
5272| 参数名    | 类型     | 必填 | 说明                           |
5273| --------- | ------- | ---- | ----------------------------- |
5274| module    | number  | 是   | 指示用于身份验证的执行器类型。   |
5275| acquire   | number  | 是   | 指示不同身份验证执行器的tip代码。|
5276| extraInfo | Uint8Array | 是   | 保留参数。                     |
5277
5278**示例:**
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
5295提供获取属性请求的信息。
5296
5297**系统接口:** 此接口为系统接口。
5298
5299**系统能力:** SystemCapability.Account.OsAccount
5300
5301| 名称    | 类型                                                          | 必填   | 说明                   |
5302| -------- | ------------------------------------------------------------- | ----- | ----------------------- |
5303| authType | [AuthType](#authtype8)                            | 是    | 身份验证凭据类型。        |
5304| keys     | Array&lt;[GetPropertyType](#getpropertytype8)&gt; | 是    | 指示要获取的属性类型数组。 |
5305| accountId<sup>12+</sup> | number | 否 | 系统账号标识,默认为undefined。 |
5306
5307## SetPropertyRequest<sup>8+</sup>
5308
5309提供设置属性请求的信息。
5310
5311**系统接口:** 此接口为系统接口。
5312
5313**系统能力:** SystemCapability.Account.OsAccount
5314
5315| 名称    | 类型                                             | 必填   | 说明                 |
5316| -------- | ------------------------------------------------ | ----- | -------------------- |
5317| authType | [AuthType](#authtype8)               | 是    | 身份验证凭据类型。     |
5318| key     | [SetPropertyType](#setpropertytype8) | 是    | 指示要设置的属性类型。 |
5319| setInfo  | Uint8Array                                       | 是    | 指示要设置的信息。     |
5320
5321## ExecutorProperty<sup>8+</sup>
5322
5323提供执行器的属性。
5324
5325**系统接口:** 此接口为系统接口。
5326
5327**系统能力:** SystemCapability.Account.OsAccount
5328
5329| 名称         | 类型                         |  可读 | 可写 | 说明              |
5330| ------------ | ---------------------------- | ----- | -----|----------------- |
5331| result       | number                       | 是    | 是   | 指示结果。         |
5332| authSubType  | [AuthSubType](#authsubtype8) | 是    | 是   | 指示认证凭据子类型。|
5333| remainTimes  | number                       | 是    | 是   | 指示剩余次数。     |
5334| freezingTime | number                       | 是    | 是   | 指示冻结时间。     |
5335| enrollmentProgress<sup>10+</sup> | string   | 是    | 是   | 指示录入进度,默认为空。 |
5336| sensorInfo<sup>10+</sup> | string           | 是    | 是   | 指示传感器信息,默认为空。 |
5337| nextPhaseFreezingTime<sup>12+</sup> | number | 是    | 是   | 指示下次冻结时间,默认为undefined。 |
5338
5339## AuthResult<sup>8+</sup>
5340
5341表示认证结果的信息。
5342
5343**系统接口:** 此接口为系统接口。
5344
5345**系统能力:** SystemCapability.Account.OsAccount
5346
5347| 名称        | 类型        | 必填   | 说明              |
5348| ------------ | ----------- | ----- | ----------------- |
5349| token        | Uint8Array  | 否    | 指示认证令牌,默认为空。      |
5350| remainTimes  | number      | 否    | 指示剩余次数,默认为空。      |
5351| freezingTime | number      | 否    | 指示冻结时间,默认为空。      |
5352| nextPhaseFreezingTime<sup>12+</sup> | number | 否    | 指示下次冻结时间,默认为undefined。 |
5353| credentialId<sup>12+</sup> | Uint8Array  | 否    | 指示凭据ID,默认为空。 |
5354| accountId<sup>12+</sup>         | number | 否    | 指示系统账号标识,默认为undefined。 |
5355| pinValidityPeriod<sup>12+</sup> | number | 否    | 指示认证有效期,默认为undefined。 |
5356
5357## CredentialInfo<sup>8+</sup>
5358
5359表示凭证信息。
5360
5361**系统接口:** 此接口为系统接口。
5362
5363**系统能力:** SystemCapability.Account.OsAccount
5364
5365| 名称        | 类型                                     | 必填   | 说明              |
5366| ------------ | ---------------------------------------- | ----- | ----------------- |
5367| credType     | [AuthType](#authtype8)       | 是    | 指示凭据类型。     |
5368| credSubType  | [AuthSubType](#authsubtype8) | 是    | 指示凭据子类型。   |
5369| token        | Uint8Array                           | 是    | 指示认证令牌。     |
5370| accountId<sup>12+</sup>    | number | 否    | 系统账号标识,默认为undefined。 |
5371
5372## RequestResult<sup>8+</sup>
5373
5374表示请求结果的信息。
5375
5376**系统接口:** 此接口为系统接口。
5377
5378**系统能力:** SystemCapability.Account.OsAccount
5379
5380| 名称        | 类型        | 必填   | 说明              |
5381| ------------ | ----------- | ----- | ----------------- |
5382| credentialId | Uint8Array  | 否    | 指示凭据索引,默认为空。      |
5383
5384## EnrolledCredInfo<sup>8+</sup>
5385
5386表示已注册凭据的信息。
5387
5388**系统接口:** 此接口为系统接口。
5389
5390**系统能力:** SystemCapability.Account.OsAccount
5391
5392| 名称        | 类型                                     | 必填   | 说明              |
5393| ------------ | ---------------------------------------- | ----- | ------------------- |
5394| credentialId | Uint8Array                               | 是    | 指示凭据索引。       |
5395| authType     | [AuthType](#authtype8)       | 是    | 指示认证凭据类型。   |
5396| authSubType  | [AuthSubType](#authsubtype8) | 是    | 指示认证凭据子类型。 |
5397| templateId   | Uint8Array                               | 是    | 指示凭据模板ID。     |
5398
5399## GetPropertyType<sup>8+</sup>
5400
5401表示要获取的属性类型的枚举。
5402
5403**系统接口:** 此接口为系统接口。
5404
5405**系统能力:** SystemCapability.Account.OsAccount
5406
5407| 名称           | 值 | 说明      |
5408| ------------- | ------ | --------- |
5409| AUTH_SUB_TYPE | 1      | 认证子类型。 |
5410| REMAIN_TIMES  | 2      | 剩余次数。   |
5411| FREEZING_TIME | 3      | 冻结时间。   |
5412| ENROLLMENT_PROGRESS<sup>10+</sup> | 4      | 录入进度。   |
5413| SENSOR_INFO<sup>10+</sup> | 5      | 传感器信息。   |
5414| NEXT_PHASE_FREEZING_TIME<sup>12+</sup> | 6 | 下次冻结时间。 |
5415
5416## SetPropertyType<sup>8+</sup>
5417
5418表示要设置的属性类型的枚举。
5419
5420**系统接口:** 此接口为系统接口。
5421
5422**系统能力:** SystemCapability.Account.OsAccount
5423
5424| 名称           | 值 | 说明        |
5425| -------------- | ----- | ----------- |
5426| INIT_ALGORITHM | 1     | 初始化算法。 |
5427
5428## AuthType<sup>8+</sup>
5429
5430表示身份验证的凭据类型的枚举。
5431
5432**系统接口:** 此接口为系统接口。
5433
5434**系统能力:** SystemCapability.Account.OsAccount
5435
5436| 名称  | 值 | 说明             |
5437| ----- | ----- | ---------------- |
5438| PIN   | 1     | 表示PIN认证类型。 |
5439| FACE  | 2     | 表示脸部认证类型。|
5440| FINGERPRINT<sup>10+</sup>   | 4     | 表示指纹认证类型。 |
5441| RECOVERY_KEY<sup>12+</sup> | 8 | 表示键恢复类型。 |
5442| DOMAIN<sup>9+</sup>  | 1024     | 表示域认证类型。|
5443
5444## AuthSubType<sup>8+</sup>
5445
5446表示用于认证的凭据子类型的枚举。
5447
5448**系统接口:** 此接口为系统接口。
5449
5450**系统能力:** SystemCapability.Account.OsAccount
5451
5452| 名称       | 值 | 说明               |
5453| ---------- | ----- | ------------------ |
5454| PIN_SIX    | 10000 | 表示6位凭证。       |
5455| PIN_NUMBER | 10001 | 表示自定义数字凭证。 |
5456| PIN_MIXED  | 10002 | 表示自定义混合凭据。 |
5457| PIN_FOUR<sup>12+</sup>   | 10003 | 表示4位凭证。 |
5458| PIN_PATTERN<sup>12+</sup>  | 10004 | 表示图案凭据。 |
5459| FACE_2D    | 20000 | 表示2D 人脸凭证。   |
5460| FACE_3D    | 20001 | 表示3D 人脸凭证。   |
5461| FINGERPRINT_CAPACITIVE<sup>10+</sup>    | 30000 | 表示电容式指纹。   |
5462| FINGERPRINT_OPTICAL<sup>10+</sup>    | 30001 | 表示光学指纹。   |
5463| FINGERPRINT_ULTRASONIC<sup>10+</sup>    | 30002 | 表示超声波指纹。   |
5464| DOMAIN_MIXED<sup>9+</sup>    | 10240001 | 表示域认证混合凭证。   |
5465
5466## AuthTrustLevel<sup>8+</sup>
5467
5468表示认证结果的受信任级别的枚举。
5469
5470**系统接口:** 此接口为系统接口。
5471
5472**系统能力:** SystemCapability.Account.OsAccount
5473
5474| 名称  | 值 | 说明        |
5475| ---- | ------ | ----------- |
5476| ATL1 | 10000  | 信任级别 1。 |
5477| ATL2 | 20000  | 信任级别 2。 |
5478| ATL3 | 30000  | 信任级别 3。 |
5479| ATL4 | 40000  | 信任级别 4。 |
5480
5481## Module<sup>8+</sup>
5482
5483表示获取信息的模块的枚举。
5484
5485**系统接口:** 此接口为系统接口。
5486
5487**系统能力:** SystemCapability.Account.OsAccount
5488
5489| 名称       | 值 | 说明                     |
5490| --------- | ------ | ------------------------ |
5491| FACE_AUTH | 1      | 表示从人脸认证获取的信息。 |
5492
5493## ResultCode<sup>8+</sup>
5494
5495表示身份验证结果码。
5496
5497**系统接口:** 此接口为系统接口。
5498
5499**系统能力:** SystemCapability.Account.OsAccount
5500
5501| 名称                    | 值 | 说明                                     |
5502| ----------------------- | ----- | ---------------------------------------- |
5503| SUCCESS                 | 0     | 表示身份验证成功或支持此功能。             |
5504| FAIL                    | 1     | 表示验证器无法识别用户。                   |
5505| GENERAL_ERROR           | 2     | 表示其他错误。                            |
5506| CANCELED                | 3     | 表示身份验证已取消。                       |
5507| TIMEOUT                 | 4     | 表示身份验证已超时。                       |
5508| TYPE_NOT_SUPPORT        | 5     | 表示不支持此身份验证类型。                 |
5509| TRUST_LEVEL_NOT_SUPPORT | 6     | 表示不支持身份验证信任级别。               |
5510| BUSY                    | 7     | 表示身份验证任务正忙。等待几秒钟,然后重试。 |
5511| INVALID_PARAMETERS      | 8     | 表示参数不正确。                          |
5512| LOCKED                  | 9     | 指示身份验证器已锁定。                     |
5513| NOT_ENROLLED            | 10    | 表示用户尚未注册验证器。                   |
5514
5515## FaceTipsCode<sup>8+</sup>
5516
5517表示人脸验证过程中提示的枚举。
5518
5519**系统接口:** 此接口为系统接口。
5520
5521**系统能力:** SystemCapability.Account.OsAccount
5522
5523| 名称                          | 值 | 说明                                     |
5524| ----------------------------- | ----- | ---------------------------------------- |
5525| FACE_AUTH_TIP_TOO_BRIGHT      | 1     | 表示由于高照明,获得的面部图像太亮。         |
5526| FACE_AUTH_TIP_TOO_DARK        | 2     | 表示由于照明度低,获得的面部图像太暗。       |
5527| FACE_AUTH_TIP_TOO_CLOSE       | 3     | 表示面部离设备太近。                       |
5528| FACE_AUTH_TIP_TOO_FAR         | 4     | 表示面部离设备太远。                       |
5529| FACE_AUTH_TIP_TOO_HIGH        | 5     | 表示设备太高,仅捕捉面部上部。              |
5530| FACE_AUTH_TIP_TOO_LOW         | 6     | 表示设备太低,仅捕捉面部下部。              |
5531| FACE_AUTH_TIP_TOO_RIGHT       | 7     | 指示设备向右偏移,并且仅捕捉面部的右侧部分。 |
5532| FACE_AUTH_TIP_TOO_LEFT        | 8     | 指示设备向左偏移,并且仅捕捉面部的左侧部分。 |
5533| FACE_AUTH_TIP_TOO_MUCH_MOTION | 9     | 表示面部信息收集过程中面部移动过快。         |
5534| FACE_AUTH_TIP_POOR_GAZE       | 10    | 表示面未朝向设备。                         |
5535| FACE_AUTH_TIP_NOT_DETECTED    | 11    | 表示未检测到人脸。                         |
5536
5537## FingerprintTips<sup>8+</sup>
5538
5539表示指纹身份验证过程中提示的枚举。
5540
5541**系统接口:** 此接口为系统接口。
5542
5543**系统能力:** SystemCapability.Account.OsAccount
5544
5545| 名称                          | 值 | 说明                                            |
5546| ----------------------------- | ----- | ----------------------------------------------- |
5547| FINGERPRINT_TIP_GOOD          | 0     | 表示采集的图像良好。                              |
5548| FINGERPRINT_TIP_IMAGER_DIRTY  | 1     | 表示由于传感器上可疑或检测到污垢,指纹图像噪声过大。 |
5549| FINGERPRINT_TIP_INSUFFICIENT  | 2     | 表示由于检测到的情况,指纹图像噪声太大,无法处理。   |
5550| FINGERPRINT_TIP_PARTIAL       | 3     | 表示仅检测到部分指纹图像。                         |
5551| FINGERPRINT_TIP_TOO_FAST      | 4     | 表示指纹图像由于快速运动而不完整。                  |
5552| FINGERPRINT_TIP_TOO_SLOW      | 5     | 表示由于缺少运动,指纹图像无法读取。                |
5553| FINGERPRINT_TIP_FINGER_DOWN<sup>10+</sup>   | 6     | 表示手指落下。                  |
5554| FINGERPRINT_TIP_FINGER_UP<sup>10+</sup>     | 7     | 表示手指抬起。                |
5555
5556## OsAccountInfo
5557
5558表示系统账号信息。
5559
5560**系统能力:** SystemCapability.Account.OsAccount
5561
5562| 名称      | 类型   | 必填 | 说明       |
5563| ----------- | ------ | ---- | ---------- |
5564| shortName<sup>12+</sup> | string | 否   | 系统账号的短名称。<br>**系统接口:** 此接口为系统接口,默认为空。 |
5565| isLoggedIn<sup>12+</sup> | boolean | 否   | 是否登录。<br>**系统接口:** 此接口为系统接口,默认为false。 |
5566
5567## OsAccountType
5568
5569表示系统账号类型的枚举。
5570
5571**系统能力:** SystemCapability.Account.OsAccount5572
5573| 名称   | 值 | 说明         |
5574| ------ | ------ | ----------- |
5575| PRIVATE<sup>12+</sup> | 1024  | 隐私账号。隐私账号只能有一个。<br>**系统接口:** 此接口为系统接口。   |
5576
5577## DomainAccountInfo<sup>8+</sup>
5578
5579表示域账号信息。
5580
5581**系统能力:** SystemCapability.Account.OsAccount
5582
5583| 名称      | 类型   | 必填 | 说明       |
5584| ----------- | ------ | ---- | ---------- |
5585| accountId<sup>10+</sup> | string | 否   | 域账号标识。<br>**系统接口:** 此接口为系统接口,默认为undefined。 |
5586| isAuthenticated<sup>11+</sup>| boolean | 否 | 指示域账号是否已认证。<br>**系统接口:** 此接口为系统接口,默认为false。|
5587| serverConfigId<sup>12+</sup>| boolean | 否 | 域账号所属服务器标识。<br>**系统接口:** 此接口为系统接口,默认为undefined。|
5588
5589## ConstraintSourceTypeInfo<sup>9+</sup>
5590
5591表示约束来源类型信息。
5592
5593**系统接口:** 此接口为系统接口。
5594
5595**系统能力:** SystemCapability.Account.OsAccount
5596
5597| 名称      | 类型   | 必填 | 说明       |
5598| ----------- | ------ | ---- | ---------- |
5599| localId      | number | 是   | 系统账号ID     |
5600| type | [ConstraintSourceType](#constraintsourcetype9) | 是   | 约束来源类型 |
5601
5602## ConstraintSourceType<sup>9+</sup>
5603
5604表示约束来源类型的枚举。
5605
5606**系统接口:** 此接口为系统接口。
5607
5608**系统能力:** SystemCapability.Account.OsAccount
5609
5610| 名称   | 值 | 说明         |
5611| ------ | ------ | ------------ |
5612| CONSTRAINT_NOT_EXIST  | 0      | 约束不存在 |
5613| CONSTRAINT_TYPE_BASE | 1      | 约束源自系统设置   |
5614| CONSTRAINT_TYPE_DEVICE_OWNER  | 2   | 约束源自设备所有者设置   |
5615| CONSTRAINT_TYPE_PROFILE_OWNER  | 3  | 约束源自资料所有者设置   |
5616
5617## AuthStatusInfo<sup>10+</sup>
5618
5619表示认证状态信息。
5620
5621**系统接口:** 此接口为系统接口。
5622
5623**系统能力:** SystemCapability.Account.OsAccount
5624
5625| 名称      | 类型   | 必填 | 说明       |
5626| ----------- | ------ | ---- | ---------- |
5627| remainTimes  | number | 是   | 剩余次数   |
5628| freezingTime | number | 是   | 冻结时间 |
5629
5630## GetDomainAccessTokenOptions<sup>10+</sup>
5631
5632表示获取域访问令牌的选项。
5633
5634**系统接口:** 此接口为系统接口。
5635
5636**系统能力:** SystemCapability.Account.OsAccount
5637
5638| 名称      | 类型   | 必填 | 说明       |
5639| ----------- | ------ | ---- | ---------- |
5640| domainAccountInfo  | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域账号的信息   |
5641| domainAccountToken | Uint8Array | 是   | 域账号的令牌 |
5642| businessParams | Record<string, Object> | 是   | 业务参数,由业务方根据请求协议自定义 |
5643| callerUid | number | 是   | 调用方唯一标识符 |
5644
5645## GetDomainAccountInfoOptions<sup>10+</sup>
5646
5647表示查询域账号信息的选项。
5648
5649**系统接口:** 此接口为系统接口。
5650
5651**系统能力:** SystemCapability.Account.OsAccount
5652
5653| 名称      | 类型   | 必填 | 说明       |
5654| ----------- | ------ | ---- | ---------- |
5655| accountName | string | 是   | 域账号名。 |
5656| domain      | string | 否   | 域名。默认为undefined。|
5657| serverConfigId<sup>12+</sup>| boolean | 否 | 域账号所属服务器标识。默认为undefined。|
5658
5659## GetDomainAccountInfoPluginOptions<sup>10+</sup>
5660
5661表示插件查询域账号信息的选项。GetDomainAccountInfoPluginOptions类继承[GetDomainAccountInfoOptions](#getdomainaccountinfooptions10)
5662
5663**系统接口:** 此接口为系统接口。
5664
5665**系统能力:** SystemCapability.Account.OsAccount
5666
5667| 名称      | 类型   | 必填 | 说明       |
5668| ----------- | ------ | ---- | ---------- |
5669| callerUid | number | 是   | 调用方唯一标识符 |
5670
5671## OsAccountSwitchEventData<sup>12+</sup>
5672
5673表示系统账号前后台开始切换和结束切换事件的数据结构。
5674
5675**系统接口:** 此接口为系统接口。
5676
5677**系统能力:** SystemCapability.Account.OsAccount
5678
5679| 名称      | 类型   | 必填 | 说明       |
5680| ----------- | ------ | ---- | ---------- |
5681| fromAccountId | number | 是   | 切换前系统账号ID |
5682| toAccountId | number | 是   | 切换后系统账号ID |
5683
5684## CreateOsAccountOptions<sup>12+</sup>
5685
5686表示用于创建系统账号的可选参数。
5687
5688**系统接口:** 此接口为系统接口。
5689
5690**系统能力:** SystemCapability.Account.OsAccount
5691
5692| 名称      | 类型   | 必填 | 说明       |
5693| ----------- | ------ | ---- | ---------- |
5694| shortName | string | 是   | 表示账号短名称(用作个人文件夹目录) <br/>**约束:** <br>1)不允许出现的字符:\< \> \| : " * ? / \\<br>2)不允许独立出现的字符串:.或..<br>3)长度不超过255个字符|
5695
5696## CreateOsAccountForDomainOptions<sup>12+</sup>
5697
5698表示用于创建与指定域账号绑定的系统账号的可选参数。继承自[CreateOsAccountOptions](#createosaccountoptions12)。
5699
5700**系统接口:** 此接口为系统接口。
5701
5702**系统能力:** SystemCapability.Account.OsAccount
5703
5704| 名称      | 类型   | 必填 | 说明       |
5705| ----------- | ------ | ---- | ---------- |
5706| shortName | string | 是   | 表示账号短名称(用作个人文件夹目录) <br/>**约束:** <br>1)不允许出现的字符:\< \> \| : " * ? / \\<br>2)不允许独立出现的字符串:.或..<br>3)长度不超过255个字符|
5707
5708## GetAuthInfoOptions<sup>12+</sup>
5709
5710表示[查询认证凭据信息](#getauthinfo12)的可选参数集合。
5711
5712**系统接口:** 此接口为系统接口。
5713
5714**系统能力:** SystemCapability.Account.OsAccount
5715
5716| 名称      | 类型                    | 必填 | 说明       |
5717| --------- | ---------------------- | ---- | ---------- |
5718| authType  | [AuthType](#authtype8) | 否   | 认证类型,默认为undefined。 |
5719| accountId | number                 | 否   | 系统账号标识,默认为undefined。 |
5720
5721## AuthIntent<sup>12+</sup>
5722
5723表示认证意图的枚举。
5724
5725**系统接口:** 此接口为系统接口。
5726
5727**系统能力:** SystemCapability.Account.OsAccount
5728
5729| 名称     | 值   | 说明       |
5730| -------- | --- | ---------- |
5731| UNLOCK   | 1   | 解锁意图。 |
5732
5733## RemoteAuthOptions<sup>12+</sup>
5734
5735表示远程认证的可选参数集合。
5736
5737**系统接口:** 此接口为系统接口。
5738
5739**系统能力:** SystemCapability.Account.OsAccount
5740
5741| 名称               | 类型    | 必填 | 说明       |
5742| ------------------ | ------ | ---- | ---------- |
5743| verifierNetworkId  | string | 否   | 凭据验证者的网络标识,默认为空。 |
5744| collectorNetworkId | string | 否   | 凭据收集者的网络标识,默认为空。 |
5745| collectorTokenId   | number | 否   | 凭据收集者的令牌标识,默认为undefined。 |
5746
5747## AuthOptions<sup>12+</sup>
5748
5749表示[认证用户](#auth12)的可选参数集合。
5750
5751**系统接口:** 此接口为系统接口。
5752
5753**系统能力:** SystemCapability.Account.OsAccount
5754
5755| 名称               | 类型    | 必填 | 说明       |
5756| ------------------ | ------ | ---- | ---------- |
5757| accountId          | number | 否   | 系统账号标识,默认为undefined。 |
5758| authIntent         | [AuthIntent](#authintent12) | 否   | 认证意图,默认为undefined。 |
5759| remoteAuthOptions  | [RemoteAuthOptions](#remoteauthoptions12) | 否   | 远程认证选项,默认为undefined。 |
5760
5761## GetInputDataOptions <sup>12+</sup>
5762
5763表示[通知调用者获取数据](#ongetdata8)的可选参数集合。
5764
5765**系统接口:** 此接口为系统接口。
5766
5767**系统能力:** SystemCapability.Account.OsAccount
5768
5769| 名称               | 类型    | 必填 | 说明       |
5770| ------------------ | ------ | ---- | ---------- |
5771| challenge          | Uint8Array | 否   | 挑战值,默认为undefined。 |
5772