• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 account_osAccount from '@ohos.account.osAccount';
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| 12300001 | System service exception. |
44| 12300002 | Invalid localId.    |
45| 12300003 | Account not found. |
46| 12300008 | Restricted Account. |
47| 12300009 | Account has been activated. |
48
49**示例:** 激活ID为100的系统帐号
50  ```ts
51  import { BusinessError } from '@ohos.base';
52  let localId: number = 100;
53  try {
54    accountManager.activateOsAccount(localId, (err: BusinessError)=>{
55      if (err) {
56        console.error(`activateOsAccount failed, code is ${err.code}, message is ${err.message}`);
57      } else {
58        console.log('activateOsAccount successfully');
59      }
60    });
61  } catch (err) {
62    console.log('activateOsAccount failed, error:' + JSON.stringify(err));
63  }
64  ```
65
66### activateOsAccount
67
68activateOsAccount(localId: number): Promise<void>
69
70激活指定系统帐号。使用Promise异步回调。
71
72**系统接口:** 此接口为系统接口。
73
74**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
75
76**系统能力:** SystemCapability.Account.OsAccount
77
78**参数:**
79
80| 参数名  | 类型   | 必填 | 说明                 |
81| ------- | ------ | ---- | -------------------- |
82| localId | number | 是   | 系统帐号ID。 |
83
84**返回值:**
85
86| 类型                | 说明                                  |
87| ------------------- | ------------------------------------ |
88| Promise<void> | Promise对象,无返回结果的Promise对象。 |
89
90**错误码:**
91
92| 错误码ID | 错误信息             |
93| -------- | ------------------- |
94| 12300001 | System service exception. |
95| 12300002 | Invalid localId.    |
96| 12300003 | Account not found. |
97| 12300008 | Restricted Account. |
98| 12300009 | Account has been activated. |
99
100**示例:** 激活ID为100的系统帐号
101  ```ts
102  import { BusinessError } from '@ohos.base';
103  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
104  let localId: number = 100;
105  try {
106    accountManager.activateOsAccount(localId).then(() => {
107      console.log('activateOsAccount successfully');
108    }).catch((err: BusinessError) => {
109      console.log('activateOsAccount failed, err:' + JSON.stringify(err));
110    });
111  } catch (e) {
112    console.log('activateOsAccount exception: ' + JSON.stringify(e));
113  }
114  ```
115
116### isOsAccountActivated<sup>11+</sup>
117
118isOsAccountActivated(localId: number): Promise&lt;boolean&gt;
119
120判断指定系统帐号是否处于激活状态。使用Promise异步回调。
121
122**系统接口:** 此接口为系统接口。
123
124**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
125
126**系统能力:** SystemCapability.Account.OsAccount
127
128**参数:**
129
130| 参数名  | 类型   | 必填 | 说明                               |
131| ------- | ------ | ---- | --------------------------------- |
132| localId | number | 是   | 系统帐号ID。 |
133
134**返回值:**
135
136| 类型                   | 说明                                                       |
137| ---------------------- | ---------------------------------------------------------- |
138| Promise&lt;boolean&gt; | Promise对象。返回true表示帐号已激活;返回false表示帐号未激活。 |
139
140**错误码:**
141
142| 错误码ID | 错误信息             |
143| -------- | ------------------- |
144| 12300001 | System service exception. |
145| 12300003 | Account not found. |
146
147**示例:** 判断ID为100的系统帐号是否处于激活状态
148
149  ```ts
150  import { BusinessError } from '@ohos.base';
151  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
152  let localId: number = 100;
153  try {
154    accountManager.isOsAccountActivated(localId).then((isActivated: boolean) => {
155      console.log('isOsAccountActivated successfully, isActivated: ' + isActivated);
156    }).catch((err: BusinessError) => {
157      console.log('isOsAccountActivated failed, error: ' + JSON.stringify(err));
158    });
159  } catch (err) {
160    console.log('isOsAccountActivated exception: ' + JSON.stringify(err));
161  }
162  ```
163
164### isOsAccountConstraintEnabled<sup>11+</sup>
165
166isOsAccountConstraintEnabled(localId: number, constraint: string): Promise&lt;boolean&gt;
167
168判断指定系统帐号是否使能指定约束。使用Promise异步回调。
169
170**系统接口:** 此接口为系统接口。
171
172**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
173
174**系统能力:** SystemCapability.Account.OsAccount
175
176**参数:**
177
178| 参数名     | 类型   | 必填 | 说明                                |
179| ---------- | ------ | ---- | ---------------------------------- |
180| localId    | number | 是   | 系统帐号ID。  |
181| constraint | string | 是   | 指定的[约束](js-apis-osAccount.md#系统帐号约束列表)名称。 |
182
183**返回值:**
184
185| 类型                   | 说明                                                                  |
186| --------------------- | --------------------------------------------------------------------- |
187| Promise&lt;boolean&gt; | Promise对象。返回true表示已使能指定的约束;返回false表示未使能指定的约束。 |
188
189**错误码:**
190
191| 错误码ID | 错误信息             |
192| -------- | ------------------- |
193| 12300001 | System service exception. |
194| 12300003 | Account not found. |
195
196**示例:** 判断ID为100的系统帐号是否有禁止使用Wi-Fi的约束
197
198  ```ts
199  import { BusinessError } from '@ohos.base';
200  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
201  let localId: number = 100;
202  let constraint: string = 'constraint.wifi';
203  try {
204    accountManager.isOsAccountConstraintEnabled(localId, constraint).then((isEnabled: boolean) => {
205      console.log('isOsAccountConstraintEnabled successfully, isEnabled: ' + isEnabled);
206    }).catch((err: BusinessError) => {
207      console.log('isOsAccountConstraintEnabled failed, error: ' + JSON.stringify(err));
208    });
209  } catch (err) {
210    console.log('isOsAccountConstraintEnabled exception: ' + JSON.stringify(err));
211  }
212  ```
213
214### isOsAccountUnlocked<sup>11+</sup>
215
216isOsAccountUnlocked(localId: number): Promise&lt;boolean&gt;
217
218检查指定系统帐号是否已验证。使用Promise异步回调。
219
220**系统接口:** 此接口为系统接口。
221
222**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
223
224**系统能力:** SystemCapability.Account.OsAccount
225
226**参数:**
227
228| 参数名  | 类型   | 必填 | 说明                                                              |
229| ------- | ------ | ---- | --------------------------------------------------------------- |
230| localId | number | 是   | 系统帐号ID。不填则检查当前系统帐号是否已验证。 |
231
232**返回值:**
233
234| 类型                   | 说明                                                               |
235| ---------------------- | ----------------------------------------------------------------- |
236| Promise&lt;boolean&gt; | Promise对象。返回true表示当前帐号已认证解锁;返回false表示当前帐号未认证解锁。 |
237
238**错误码:**
239
240| 错误码ID | 错误信息             |
241| -------- | ------------------- |
242| 12300001 | System service exception. |
243| 12300003 | Account not found. |
244
245**示例:**
246
247  ```ts
248  import { BusinessError } from '@ohos.base';
249  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
250  let localId: number = 100;
251  try {
252    accountManager.isOsAccountUnlocked(localId).then((isVerified: boolean) => {
253      console.log('isOsAccountUnlocked successfully, isVerified: ' + isVerified);
254    }).catch((err: BusinessError) => {
255      console.log('isOsAccountUnlocked failed, error: ' + JSON.stringify(err));
256    });
257  } catch (err) {
258    console.log('isOsAccountUnlocked exception: ' + JSON.stringify(err));
259  }
260  ```
261
262### removeOsAccount
263
264removeOsAccount(localId: number, callback: AsyncCallback&lt;void&gt;): void
265
266删除指定系统帐号。使用callback异步回调。
267
268**系统接口:** 此接口为系统接口。
269
270**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
271
272**系统能力:** SystemCapability.Account.OsAccount
273
274**参数:**
275
276| 参数名   | 类型                      | 必填 | 说明                                                 |
277| -------- | ------------------------- | ---- | -------------------------------------------------- |
278| localId  | number                    | 是   | 系统帐号ID。                  |
279| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。如果删除帐号成功,err为null,否则为错误对象。 |
280
281**错误码:**
282
283| 错误码ID | 错误信息             |
284| -------- | ------------------- |
285| 12300001 | System service exception. |
286| 12300002 | Invalid localId.    |
287| 12300003 | Account not found. |
288| 12300008 | Restricted Account. |
289
290**示例:**
291
292  ```ts
293  import { BusinessError } from '@ohos.base';
294  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
295  let accountName: string = 'testAccountName';
296  try {
297    accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL,
298      (err: BusinessError, osAccountInfo: account_osAccount.OsAccountInfo) => {
299        accountManager.removeOsAccount(osAccountInfo.localId, (err: BusinessError)=>{
300          if (err) {
301            console.log('removeOsAccount failed, error: ' + JSON.stringify(err));
302          } else {
303            console.log('removeOsAccount successfully');
304          }
305      });
306    });
307  } catch (err) {
308    console.log('removeOsAccount exception: ' + JSON.stringify(err));
309  }
310  ```
311
312### removeOsAccount
313
314removeOsAccount(localId: number): Promise&lt;void&gt;
315
316删除指定系统帐号。使用Promise异步回调。
317
318**系统接口:** 此接口为系统接口。
319
320**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
321
322**系统能力:** SystemCapability.Account.OsAccount
323
324**参数:**
325
326| 参数名  | 类型   | 必填 | 说明                               |
327| ------- | ------ | ---- | --------------------------------- |
328| localId | number | 是   | 系统帐号ID。 |
329
330**返回值:**
331
332| 类型                | 说明                                  |
333| ------------------- | ------------------------------------ |
334| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
335
336**错误码:**
337
338| 错误码ID | 错误信息             |
339| -------- | ------------------- |
340| 12300001 | System service exception. |
341| 12300002 | Invalid localId.    |
342| 12300003 | Account not found. |
343| 12300008 | Restricted Account. |
344
345**示例:**
346
347  ```ts
348  import { BusinessError } from '@ohos.base';
349  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
350  let accountName: string = 'testAccountName';
351  try {
352    accountManager.createOsAccount(accountName, account_osAccount.OsAccountType.NORMAL,
353      (err: BusinessError, osAccountInfo: account_osAccount.OsAccountInfo)=>{
354        accountManager.removeOsAccount(osAccountInfo.localId).then(() => {
355          console.log('removeOsAccount successfully');
356        }).catch((err: BusinessError) => {
357            console.log('removeOsAccount failed, error: ' + JSON.stringify(err));
358        });
359    });
360  } catch (err) {
361    console.log('removeOsAccount exception: ' + JSON.stringify(err));
362  }
363  ```
364
365### setOsAccountConstraints
366
367setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean,callback: AsyncCallback&lt;void&gt;): void
368
369为指定系统帐号设置/删除约束。使用callback异步回调。
370
371**系统接口:** 此接口为系统接口。
372
373**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
374
375**系统能力:** SystemCapability.Account.OsAccount
376
377**参数:**
378
379| 参数名      | 类型                      | 必填 | 说明                                             |
380| ----------- | ------------------------- | ---- | ----------------------------------------------- |
381| localId     | number                    | 是   | 系统帐号ID。               |
382| constraints | Array&lt;string&gt;       | 是   | 待设置/删除的[约束](js-apis-osAccount.md#系统帐号约束列表)列表。        |
383| enable      | boolean                   | 是   | 设置(true)/删除(false)                           |
384| callback    | AsyncCallback&lt;void&gt; | 是   | 回调函数。如果设置成功,err为null,否则为错误对象。 |
385
386**错误码:**
387
388| 错误码ID | 错误信息             |
389| -------- | ------------------- |
390| 12300001 | System service exception. |
391| 12300002 | Invalid localId or constraints.    |
392| 12300003 | Account not found. |
393| 12300008 | Restricted Account. |
394
395**示例:** 给ID为100的系统帐号设置禁止使用Wi-Fi的约束
396
397  ```ts
398  import { BusinessError } from '@ohos.base';
399  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
400  let localId: number = 100;
401  let constraint: string = 'constraint.wifi';
402  try {
403    accountManager.setOsAccountConstraints(localId, [constraint], true, (err: BusinessError) => {
404      if (err) {
405        console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
406      } else {
407        console.log('setOsAccountConstraints successfully');
408      }
409    });
410  } catch (err) {
411    console.log('setOsAccountConstraints exception: ' + JSON.stringify(err));
412  }
413  ```
414
415### setOsAccountConstraints
416
417setOsAccountConstraints(localId: number, constraints: Array&lt;string&gt;, enable: boolean): Promise&lt;void&gt;
418
419为指定系统帐号设置/删除约束。使用Promise异步回调。
420
421**系统接口:** 此接口为系统接口。
422
423**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
424
425**系统能力:** SystemCapability.Account.OsAccount
426
427**参数:**
428
429| 参数名      | 类型                | 必填 | 说明                                         |
430| ----------- | ------------------- | ---- | -------------------------------------------- |
431| localId     | number              | 是   | 系统帐号ID。           |
432| constraints | Array&lt;string&gt; | 是   | 待设置/删除的[约束](js-apis-osAccount.md#系统帐号约束列表)列表。    |
433| enable      | boolean             | 是   | 设置(true)/删除(false)。                     |
434
435**返回值:**
436
437| 类型                | 说明                                 |
438| :------------------ | :----------------------------------- |
439| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
440
441**错误码:**
442
443| 错误码ID | 错误信息             |
444| -------- | ------------------- |
445| 12300001 | System service exception. |
446| 12300002 | Invalid localId or constraints.    |
447| 12300003 | Account not found. |
448| 12300008 | Restricted Account. |
449
450**示例:** 删除ID为100的系统帐号的禁止使用Wi-Fi的约束
451
452  ```ts
453  import { BusinessError } from '@ohos.base';
454  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
455  let localId: number = 100;
456  try {
457    accountManager.setOsAccountConstraints(localId, ['constraint.location.set'], false).then(() => {
458      console.log('setOsAccountConstraints succsuccessfully');
459    }).catch((err: BusinessError) => {
460      console.log('setOsAccountConstraints failed, error: ' + JSON.stringify(err));
461    });
462  } catch (err) {
463    console.log('setOsAccountConstraints exception: ' + JSON.stringify(err));
464  }
465  ```
466
467### setOsAccountName
468
469setOsAccountName(localId: number, localName: string, callback: AsyncCallback&lt;void&gt;): void
470
471设置指定系统帐号的帐号名。使用callback异步回调。
472
473**系统接口:** 此接口为系统接口。
474
475**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
476
477**系统能力:** SystemCapability.Account.OsAccount
478
479**参数:**
480
481| 参数名    | 类型                      | 必填 | 说明                                             |
482| :-------- | ------------------------- | ---- | ----------------------------------------------- |
483| localId   | number                    | 是   | 系统帐号ID。               |
484| localName | string                    | 是   | 帐号名,最大长度为1024个字符。                          |
485| callback  | AsyncCallback&lt;void&gt; | 是   | 回调函数。如果设置成功,err为null,否则为错误对象。 |
486
487**错误码:**
488
489| 错误码ID | 错误信息             |
490| -------- | ------------------- |
491| 12300001 | System service exception. |
492| 12300002 | Invalid localId or localName. |
493| 12300003 | Account not found. |
494| 12300008 | Restricted Account. |
495
496**示例:** 将ID为100的系统帐号的帐号名设置成demoName
497
498  ```ts
499  import { BusinessError } from '@ohos.base';
500  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
501  let localId: number = 100;
502  let name: string = 'demoName';
503  try {
504    accountManager.setOsAccountName(localId, name, (err: BusinessError) => {
505      if (err) {
506        console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
507      } else {
508        console.log('setOsAccountName successfully');
509      }
510    });
511  } catch (err) {
512    console.log('setOsAccountName exception: ' + JSON.stringify(err));
513  }
514  ```
515
516### setOsAccountName
517
518setOsAccountName(localId: number, localName: string): Promise&lt;void&gt;
519
520设置指定系统帐号的帐号名。使用Promise异步调用。
521
522**系统接口:** 此接口为系统接口。
523
524**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
525
526**系统能力:** SystemCapability.Account.OsAccount
527
528**参数:**
529
530| 参数名    | 类型   | 必填 | 说明                                |
531| --------- | ------ | ---- | --------------------------------- |
532| localId   | number | 是   | 系统帐号ID。 |
533| localName | string | 是   | 帐号名,最大长度为1024。            |
534
535**返回值:**
536
537| 类型                | 说明                                  |
538| ------------------- | ------------------------------------ |
539| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
540
541**错误码:**
542
543| 错误码ID | 错误信息             |
544| -------- | ------------------- |
545| 12300001 | System service exception. |
546| 12300002 | Invalid localId or localName.    |
547| 12300003 | Account not found. |
548| 12300008 | Restricted Account. |
549
550**示例:** 将ID为100的系统帐号的帐号名设置成demoName
551
552  ```ts
553  import { BusinessError } from '@ohos.base';
554  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
555  let localId: number = 100;
556  let name: string = 'testName';
557  try {
558    accountManager.setOsAccountName(localId, name).then(() => {
559      console.log('setOsAccountName successfully');
560    }).catch((err: BusinessError) => {
561      console.log('setOsAccountName failed, error: ' + JSON.stringify(err));
562    });
563  } catch (err) {
564    console.log('setOsAccountName exception: ' + JSON.stringify(err));
565  }
566  ```
567
568### queryMaxOsAccountNumber
569
570queryMaxOsAccountNumber(callback: AsyncCallback&lt;number&gt;): void
571
572查询允许创建的系统帐号的最大数量。使用callback异步回调。
573
574**系统接口:** 此接口为系统接口。
575
576**系统能力:** SystemCapability.Account.OsAccount
577
578**参数:**
579
580| 参数名   | 类型                        | 必填 | 说明                                                                              |
581| -------- | --------------------------- | ---- | -------------------------------------------------------------------------------- |
582| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数,如果查询成功,err为null,data为允许创建的系统帐号的最大数量;否则为错误对象。 |
583
584**错误码:**
585
586| 错误码ID | 错误信息       |
587| -------- | ------------- |
588| 12300001 | System service exception. |
589
590**示例:**
591
592  ```ts
593  import { BusinessError } from '@ohos.base';
594  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
595  try {
596    accountManager.queryMaxOsAccountNumber((err: BusinessError, maxCnt: number) => {
597      if (err) {
598        console.log('queryMaxOsAccountNumber failed, error:' + JSON.stringify(err));
599      } else {
600        console.log('queryMaxOsAccountNumber successfully, maxCnt:' + maxCnt);
601      }
602    });
603  } catch (err) {
604    console.log('queryMaxOsAccountNumber exception: ' + JSON.stringify(err));
605  }
606  ```
607
608### queryMaxOsAccountNumber
609
610queryMaxOsAccountNumber(): Promise&lt;number&gt;
611
612查询允许创建的系统帐号的最大数量。使用Promise异步回调。
613
614**系统接口:** 此接口为系统接口。
615
616**系统能力:** SystemCapability.Account.OsAccount
617
618**返回值:**
619
620| 类型                  | 说明                                         |
621| --------------------- | ------------------------------------------- |
622| Promise&lt;number&gt; | Promise对象,返回允许创建的系统帐号的最大数量。 |
623
624**错误码:**
625
626| 错误码ID | 错误信息       |
627| -------- | ------------- |
628| 12300001 | System service exception. |
629
630**示例:**
631
632  ```ts
633  import { BusinessError } from '@ohos.base';
634  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
635  try {
636    accountManager.queryMaxOsAccountNumber().then((maxCnt: number) => {
637      console.log('queryMaxOsAccountNumber successfully, maxCnt: ' + maxCnt);
638    }).catch((err: BusinessError) => {
639      console.log('queryMaxOsAccountNumber failed, error: ' + JSON.stringify(err));
640    });
641  } catch (err) {
642    console.log('queryMaxOsAccountNumber exception: ' + JSON.stringify(err));
643  }
644  ```
645
646### getEnabledOsAccountConstraints<sup>11+</sup>
647
648getEnabledOsAccountConstraints(localId: number): Promise&lt;Array&lt;string&gt;&gt;
649
650获取指定系统帐号已使能的的全部约束。使用Promise异步回调。
651
652**系统接口:** 此接口为系统接口。
653
654**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS
655
656**系统能力:** SystemCapability.Account.OsAccount
657
658**参数:**
659
660| 参数名  | 类型   | 必填 | 说明         |
661| ------- | ------ | ---- | ------------ |
662| localId | number | 是   | 系统帐号ID。 |
663
664**返回值:**
665
666| 类型                               | 说明                                                       |
667| ---------------------------------- | ---------------------------------------------------------- |
668| Promise&lt;Array&lt;string&gt;&gt; | Promise对象,返回指定系统帐号已使能的的全部[约束](js-apis-osAccount.md#系统帐号约束列表)。 |
669
670**错误码:**
671
672| 错误码ID | 错误信息             |
673| -------- | ------------------- |
674| 12300001 | System service exception. |
675| 12300003 | Account not found. |
676
677**示例:** 获取ID为100的系统帐号的全部约束
678
679  ```ts
680  import { BusinessError } from '@ohos.base';
681  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
682  let localId: number = 100;
683  try {
684    accountManager.getEnabledOsAccountConstraints(localId).then((constraints: string[]) => {
685      console.log('getEnabledOsAccountConstraints, constraints: ' + constraints);
686    }).catch((err: BusinessError) => {
687      console.log('getEnabledOsAccountConstraints err: ' + JSON.stringify(err));
688    });
689  } catch (e) {
690    console.log('getEnabledOsAccountConstraints exception: ' + JSON.stringify(e));
691  }
692  ```
693
694### queryAllCreatedOsAccounts
695
696queryAllCreatedOsAccounts(callback: AsyncCallback&lt;Array&lt;OsAccountInfo&gt;&gt;): void
697
698查询已创建的所有系统帐号的信息列表。使用callback异步回调。
699
700**系统接口:** 此接口为系统接口。
701
702**系统能力:** SystemCapability.Account.OsAccount
703
704**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
705
706**参数:**
707
708| 参数名   | 类型                                                         | 必填 | 说明                                               |
709| -------- | ------------------------------------------------------------ | ---- | -------------------------------------------------- |
710| callback | AsyncCallback&lt;Array&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt;&gt; | 是   | 回调函数。如果查询成功,err为null,data为已创建的所有系统帐号的信息列表;否则为错误对象。 |
711
712**错误码:**
713
714| 错误码ID | 错误信息       |
715| -------- | ------------- |
716| 12300001 | System service exception. |
717
718**示例:**
719
720  ```ts
721  import { BusinessError } from '@ohos.base';
722  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
723  try {
724    accountManager.queryAllCreatedOsAccounts((err: BusinessError, accountArr: account_osAccount.OsAccountInfo[])=>{
725      console.log('queryAllCreatedOsAccounts err:' + JSON.stringify(err));
726      console.log('queryAllCreatedOsAccounts accountArr:' + JSON.stringify(accountArr));
727    });
728  } catch (e) {
729    console.log('queryAllCreatedOsAccounts exception: ' + JSON.stringify(e));
730  }
731  ```
732
733### queryAllCreatedOsAccounts
734
735queryAllCreatedOsAccounts(): Promise&lt;Array&lt;OsAccountInfo&gt;&gt;
736
737查询已创建的所有系统帐号的信息列表。使用Promise异步回调。
738
739**系统接口:** 此接口为系统接口。
740
741**系统能力:** SystemCapability.Account.OsAccount
742
743**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
744
745**返回值:**
746
747| 类型                                                        | 说明                                           |
748| ----------------------------------------------------------- | --------------------------------------------- |
749| Promise&lt;Array&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt;&gt; | Promise对象,返回已创建的所有系统帐号的信息列表。 |
750
751**错误码:**
752
753| 错误码ID | 错误信息       |
754| -------- | ------------- |
755| 12300001 | System service exception. |
756
757**示例:**
758
759  ```ts
760  import { BusinessError } from '@ohos.base';
761  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
762  try {
763    accountManager.queryAllCreatedOsAccounts().then((accountArr: account_osAccount.OsAccountInfo[]) => {
764      console.log('queryAllCreatedOsAccounts, accountArr: ' + JSON.stringify(accountArr));
765    }).catch((err: BusinessError) => {
766      console.log('queryAllCreatedOsAccounts err: ' + JSON.stringify(err));
767    });
768  } catch (e) {
769    console.log('queryAllCreatedOsAccounts exception: ' + JSON.stringify(e));
770  }
771  ```
772
773### createOsAccount
774
775createOsAccount(localName: string, type: OsAccountType, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
776
777创建一个系统帐号。使用callback异步回调。
778
779**系统接口:** 此接口为系统接口。
780
781**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
782
783**系统能力:** SystemCapability.Account.OsAccount
784
785**参数:**
786
787| 参数名    | 类型                                                 | 必填 | 说明                                                                         |
788| :-------- | ---------------------------------------------------- | ---- | --------------------------------------------------------------------------- |
789| localName | string                                               | 是   | 创建的系统帐号的名称。                                                        |
790| type      | [OsAccountType](js-apis-osAccount.md#osaccounttype)                      | 是   | 创建的系统帐号的类型。                                                        |
791| callback  | AsyncCallback&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | 是   | 回调函数。如果创建成功,err为null,data为新创建的系统帐号的信息;否则为错误对象。 |
792
793**错误码:**
794
795| 错误码ID  | 错误信息                   |
796| -------- | ------------------------- |
797| 12300001 | System service exception. |
798| 12300002 | Invalid localName or type. |
799| 12300005 | Multi-user not supported. |
800| 12300006 | Unsupported account type. |
801| 12300007 | The number of accounts reaches the upper limit. |
802
803**示例:**
804
805  ```ts
806  import { BusinessError } from '@ohos.base';
807  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
808  try {
809    accountManager.createOsAccount('testName', account_osAccount.OsAccountType.NORMAL,
810      (err: BusinessError, osAccountInfo: account_osAccount.OsAccountInfo)=>{
811      console.log('createOsAccount err:' + JSON.stringify(err));
812      console.log('createOsAccount osAccountInfo:' + JSON.stringify(osAccountInfo));
813    });
814  } catch (e) {
815    console.log('createOsAccount exception: ' + JSON.stringify(e));
816  }
817  ```
818
819### createOsAccount
820
821createOsAccount(localName: string, type: OsAccountType): Promise&lt;OsAccountInfo&gt;
822
823创建一个系统帐号。使用Promise异步回调。
824
825**系统接口:** 此接口为系统接口。
826
827**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
828
829**系统能力:** SystemCapability.Account.OsAccount
830
831**参数:**
832
833| 参数名    | 类型                            | 必填 | 说明                   |
834| --------- | ------------------------------- | ---- | ---------------------- |
835| localName | string                          | 是   | 创建的系统帐号的名称。 |
836| type      | [OsAccountType](js-apis-osAccount.md#osaccounttype) | 是   | 创建的系统帐号的类型。 |
837
838**返回值:**
839
840| 类型                                           | 说明                                  |
841| ---------------------------------------------- | ------------------------------------- |
842| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise对象,返回新创建的系统帐号的信息。 |
843
844**错误码:**
845
846| 错误码ID  | 错误信息                   |
847| -------- | ------------------------- |
848| 12300001 | System service exception. |
849| 12300002 | Invalid localName or type. |
850| 12300005 | Multi-user not supported. |
851| 12300006 | Unsupported account type. |
852| 12300007 | The number of accounts reaches the upper limit. |
853
854**示例:**
855
856  ```ts
857  import { BusinessError } from '@ohos.base';
858  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
859  try {
860    accountManager.createOsAccount('testAccountName', account_osAccount.OsAccountType.NORMAL).then(
861      (accountInfo: account_osAccount.OsAccountInfo) => {
862      console.log('createOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
863    }).catch((err: BusinessError) => {
864      console.log('createOsAccount err: ' + JSON.stringify(err));
865    });
866  } catch (e) {
867    console.log('createOsAccount exception: ' + JSON.stringify(e));
868  }
869  ```
870
871### createOsAccountForDomain<sup>8+</sup>
872
873createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
874
875根据域帐号信息,创建一个系统帐号并将其与域帐号关联。使用callback异步回调。
876
877**系统接口:** 此接口为系统接口。
878
879**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
880
881**系统能力:** SystemCapability.Account.OsAccount
882
883**参数:**
884
885| 参数名     | 类型                                                 | 必填 | 说明                                                                         |
886| ---------- | ---------------------------------------------------- | ---- | -------------------------------------------------------------------------- |
887| type       | [OsAccountType](js-apis-osAccount.md#osaccounttype)                      | 是   | 创建的系统帐号的类型。                                                       |
888| domainInfo | [DomainAccountInfo](#domainaccountinfo8)              | 是   | 域帐号信息。                                                               |
889| callback   | AsyncCallback&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | 是   | 回调函数。如果创建成功,err为null,data为新创建的系统帐号的信息;否则为错误对象。 |
890
891**错误码:**
892
893| 错误码ID | 错误信息                     |
894| -------- | ------------------- |
895| 12300001 | System service exception. |
896| 12300002 | Invalid type or domainInfo. |
897| 12300004 | Account already exists. |
898| 12300005 | Multi-user not supported. |
899| 12300006 | Unsupported account type. |
900| 12300007 | The number of accounts reaches the upper limit. |
901
902**示例:**
903
904  ```ts
905  import { BusinessError } from '@ohos.base';
906  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
907  let domainInfo: account_osAccount.DomainAccountInfo =
908    {domain: 'testDomain', accountName: 'testAccountName'};
909  try {
910    accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo,
911      (err: BusinessError, osAccountInfo: account_osAccount.OsAccountInfo)=>{
912      console.log('createOsAccountForDomain err:' + JSON.stringify(err));
913      console.log('createOsAccountForDomain osAccountInfo:' + JSON.stringify(osAccountInfo));
914    });
915  } catch (e) {
916    console.log('createOsAccountForDomain exception: ' + JSON.stringify(e));
917  }
918  ```
919
920### createOsAccountForDomain<sup>8+</sup>
921
922createOsAccountForDomain(type: OsAccountType, domainInfo: DomainAccountInfo): Promise&lt;OsAccountInfo&gt;
923
924根据传入的域帐号信息,创建与其关联的系统帐号。使用Promise异步回调。
925
926**系统接口:** 此接口为系统接口。
927
928**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
929
930**系统能力:** SystemCapability.Account.OsAccount
931
932**参数:**
933
934| 参数名     | 类型                                      | 必填 | 说明                 |
935| ---------- | ---------------------------------------- | ---- | -------------------- |
936| type       | [OsAccountType](js-apis-osAccount.md#osaccounttype)          | 是   | 创建的系统帐号的类型。 |
937| domainInfo | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域帐号信息。          |
938
939**返回值:**
940
941| 类型                                           | 说明                                    |
942| ---------------------------------------------- | -------------------------------------- |
943| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise对象,返回新创建的系统帐号的信息。 |
944
945**错误码:**
946
947| 错误码ID | 错误信息                     |
948| -------- | ------------------- |
949| 12300001 | System service exception. |
950| 12300002 | Invalid type or domainInfo. |
951| 12300004 | Account already exists. |
952| 12300005 | Multi-user not supported. |
953| 12300006 | Unsupported account type. |
954| 12300007 | The number of accounts reaches the upper limit. |
955
956**示例:**
957
958  ```ts
959  import { BusinessError } from '@ohos.base';
960  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
961  let domainInfo: account_osAccount.DomainAccountInfo =
962    {domain: 'testDomain', accountName: 'testAccountName'};
963  try {
964    accountManager.createOsAccountForDomain(account_osAccount.OsAccountType.NORMAL, domainInfo).then(
965      (accountInfo: account_osAccount.OsAccountInfo) => {
966      console.log('createOsAccountForDomain, account info: ' + JSON.stringify(accountInfo));
967    }).catch((err: BusinessError) => {
968      console.log('createOsAccountForDomain err: ' + JSON.stringify(err));
969    });
970  } catch (e) {
971    console.log('createOsAccountForDomain exception: ' + JSON.stringify(e));
972  }
973  ```
974
975### queryOsAccount<sup>11+</sup>
976
977queryOsAccount(): Promise&lt;OsAccountInfo&gt;
978
979查询当前进程所属的系统帐号的信息。使用Promise异步回调。
980
981**系统接口:** 此接口为系统接口。
982
983**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.GET_LOCAL_ACCOUNTS
984
985**系统能力:** SystemCapability.Account.OsAccount
986
987**返回值:**
988
989| 类型                                           | 说明                                       |
990| ---------------------------------------------- | ----------------------------------------- |
991| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise对象,返回当前进程所属的系统帐号信息。 |
992
993**错误码:**
994
995| 错误码ID | 错误信息             |
996| -------- | ------------------- |
997| 12300001 | System service exception. |
998
999**示例:**
1000
1001  ```ts
1002  import { BusinessError } from '@ohos.base';
1003  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1004  try {
1005    accountManager.queryOsAccount().then((accountInfo: account_osAccount.OsAccountInfo) => {
1006      console.log('queryOsAccount, accountInfo: ' + JSON.stringify(accountInfo));
1007    }).catch((err: BusinessError) => {
1008      console.log('queryOsAccount err: ' + JSON.stringify(err));
1009    });
1010  } catch (e) {
1011    console.log('queryOsAccount exception: ' + JSON.stringify(e));
1012  }
1013  ```
1014
1015### queryOsAccountById
1016
1017queryOsAccountById(localId: number, callback: AsyncCallback&lt;OsAccountInfo&gt;): void
1018
1019查询指定系统帐号的信息。使用callback异步回调。
1020
1021**系统接口:** 此接口为系统接口。
1022
1023**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1024
1025**系统能力:** SystemCapability.Account.OsAccount
1026
1027**参数:**
1028
1029| 参数名   | 类型                                                 | 必填 | 说明                                                                       |
1030| -------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------------------ |
1031| localId  | number                                               | 是   | 要查询的系统帐号的ID。                                                      |
1032| callback | AsyncCallback&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | 是   | 回调函数。如果查询成功,err为null,data为查到的系统帐号的信息;否则为错误对象。 |
1033
1034**错误码:**
1035
1036| 错误码ID | 错误信息             |
1037| -------- | ------------------- |
1038| 12300001 | System service exception. |
1039| 12300002 | Invalid localId.    |
1040| 12300003 | Account not found. |
1041
1042**示例:** 查询ID为100的系统帐号信息
1043
1044  ```ts
1045  import { BusinessError } from '@ohos.base';
1046  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1047  let localId: number = 100;
1048  try {
1049    accountManager.queryOsAccountById(localId, (err: BusinessError, accountInfo: account_osAccount.OsAccountInfo)=>{
1050      console.log('queryOsAccountById err:' + JSON.stringify(err));
1051      console.log('queryOsAccountById accountInfo:' + JSON.stringify(accountInfo));
1052    });
1053  } catch (e) {
1054    console.log('queryOsAccountById exception: ' + JSON.stringify(e));
1055  }
1056  ```
1057
1058### queryOsAccountById
1059
1060queryOsAccountById(localId: number): Promise&lt;OsAccountInfo&gt;
1061
1062查询指定系统帐号的信息。使用Promise异步回调。
1063
1064**系统接口:** 此接口为系统接口。
1065
1066**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTSohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1067
1068**系统能力:** SystemCapability.Account.OsAccount
1069
1070**参数:**
1071
1072| 参数名  | 类型   | 必填 | 说明                 |
1073| ------- | ------ | ---- | -------------------- |
1074| localId | number | 是   | 要查询的系统帐号的ID |
1075
1076**返回值:**
1077
1078| 类型                                           | 说明                                 |
1079| ---------------------------------------------- | ------------------------------------ |
1080| Promise&lt;[OsAccountInfo](js-apis-osAccount.md#osaccountinfo)&gt; | Promise对象,返回查到的系统帐号的信息。 |
1081
1082**错误码:**
1083
1084| 错误码ID | 错误信息             |
1085| -------- | ------------------- |
1086| 12300001 | System service exception. |
1087| 12300002 | Invalid localId. |
1088| 12300003 | Account not found. |
1089
1090**示例:** 查询ID为100的系统帐号信息
1091
1092  ```ts
1093  import { BusinessError } from '@ohos.base';
1094  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1095  let localId: number = 100;
1096  try {
1097    accountManager.queryOsAccountById(localId).then((accountInfo: account_osAccount.OsAccountInfo) => {
1098      console.log('queryOsAccountById, accountInfo: ' + JSON.stringify(accountInfo));
1099    }).catch((err: BusinessError) => {
1100      console.log('queryOsAccountById err: ' + JSON.stringify(err));
1101    });
1102  } catch (e) {
1103    console.log('queryOsAccountById exception: ' + JSON.stringify(e));
1104  }
1105  ```
1106
1107### getOsAccountProfilePhoto
1108
1109getOsAccountProfilePhoto(localId: number, callback: AsyncCallback&lt;string&gt;): void
1110
1111获取指定系统帐号的头像信息。使用callback异步回调。
1112
1113**系统接口:** 此接口为系统接口。
1114
1115**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1116
1117**系统能力:** SystemCapability.Account.OsAccount
1118
1119**参数:**
1120
1121| 参数名   | 类型                        | 必填 | 说明                                                                         |
1122| -------- | --------------------------- | ---- | -------------------------------------------------------------------------- |
1123| localId  | number                      | 是   | 系统帐号ID。                                                                |
1124| callback | AsyncCallback&lt;string&gt; | 是   | 回调函数。如果获取成功,err为null,data为指定系统帐号的头像信息;否则为错误对象。 |
1125
1126**错误码:**
1127
1128| 错误码ID | 错误信息             |
1129| -------- | ------------------- |
1130| 12300001 | System service exception. |
1131| 12300002 | Invalid localId.    |
1132| 12300003 | Account not found. |
1133
1134**示例:** 获取ID为100的系统帐号的头像
1135
1136  ```ts
1137  import { BusinessError } from '@ohos.base';
1138  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1139  let localId: number = 100;
1140  try {
1141    accountManager.getOsAccountProfilePhoto(localId, (err: BusinessError, photo: string)=>{
1142      console.log('getOsAccountProfilePhoto err:' + JSON.stringify(err));
1143      console.log('get photo:' + photo + ' by localId: ' + localId);
1144    });
1145  } catch (e) {
1146    console.log('getOsAccountProfilePhoto exception: ' + JSON.stringify(e));
1147  }
1148  ```
1149
1150### getOsAccountProfilePhoto
1151
1152getOsAccountProfilePhoto(localId: number): Promise&lt;string&gt;
1153
1154获取指定系统帐号的头像信息。使用Promise异步回调。
1155
1156**系统接口:** 此接口为系统接口。
1157
1158**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1159
1160**系统能力:** SystemCapability.Account.OsAccount
1161
1162**参数:**
1163
1164| 参数名  | 类型   | 必填 | 说明         |
1165| ------- | ------ | ---- | ------------ |
1166| localId | number | 是   | 系统帐号ID。 |
1167
1168**返回值:**
1169
1170| 类型                  | 说明                                    |
1171| --------------------- | -------------------------------------- |
1172| Promise&lt;string&gt; | Promise对象,返回指定系统帐号的头像信息。 |
1173
1174**错误码:**
1175
1176| 错误码ID | 错误信息             |
1177| -------- | ------------------- |
1178| 12300001 | System service exception. |
1179| 12300002 | Invalid localId.    |
1180| 12300003 | Account not found. |
1181
1182**示例:** 获取ID为100的系统帐号的头像
1183
1184  ```ts
1185  import { BusinessError } from '@ohos.base';
1186  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1187  let localId: number = 100;
1188  try {
1189    accountManager.getOsAccountProfilePhoto(localId).then((photo: string) => {
1190      console.log('getOsAccountProfilePhoto: ' + photo);
1191    }).catch((err: BusinessError) => {
1192      console.log('getOsAccountProfilePhoto err: ' + JSON.stringify(err));
1193    });
1194  } catch (e) {
1195    console.log('getOsAccountProfilePhoto exception: ' + JSON.stringify(e));
1196  }
1197  ```
1198
1199### setOsAccountProfilePhoto
1200
1201setOsAccountProfilePhoto(localId: number, photo: string, callback: AsyncCallback&lt;void&gt;): void
1202
1203为指定系统帐号设置头像信息。使用callback异步回调。
1204
1205**系统接口:** 此接口为系统接口。
1206
1207**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1208
1209**系统能力:** SystemCapability.Account.OsAccount
1210
1211**参数:**
1212
1213| 参数名   | 类型                      | 必填 | 说明         |
1214| -------- | ------------------------- | ---- | ------------ |
1215| localId  | number                    | 是   | 系统帐号ID。 |
1216| photo    | string                    | 是   | 头像信息。   |
1217| callback | AsyncCallback&lt;void&gt; | 是   | 回调函数。如果设置成功,err为null,否则为错误对象。  |
1218
1219**错误码:**
1220
1221| 错误码ID | 错误信息             |
1222| -------- | ------------------- |
1223| 12300001 | System service exception. |
1224| 12300002 | Invalid localId or photo.    |
1225| 12300003 | Account not found. |
1226| 12300008 | Restricted Account. |
1227
1228**示例:** 给ID为100的系统帐号设置头像
1229
1230  ```ts
1231  import { BusinessError } from '@ohos.base';
1232  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1233  let localId: number = 100;
1234  let photo: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
1235  'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
1236  'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
1237  '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
1238  try {
1239    accountManager.setOsAccountProfilePhoto(localId, photo, (err: BusinessError)=>{
1240      console.log('setOsAccountProfilePhoto err:' + JSON.stringify(err));
1241    });
1242  } catch (e) {
1243    console.log('setOsAccountProfilePhoto exception: ' + JSON.stringify(e));
1244  }
1245  ```
1246
1247### setOsAccountProfilePhoto
1248
1249setOsAccountProfilePhoto(localId: number, photo: string): Promise&lt;void&gt;
1250
1251为指定系统帐号设置头像信息。使用Promise异步回调。
1252
1253**系统接口:** 此接口为系统接口。
1254
1255**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1256
1257**系统能力:** SystemCapability.Account.OsAccount
1258
1259**参数:**
1260
1261| 参数名  | 类型   | 必填 | 说明         |
1262| ------- | ------ | ---- | ------------ |
1263| localId | number | 是   | 系统帐号ID。 |
1264| photo   | string | 是   | 头像信息。   |
1265
1266**返回值:**
1267
1268| 类型                | 说明                                 |
1269| ------------------- | ------------------------------------ |
1270| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
1271
1272**错误码:**
1273
1274| 错误码ID | 错误信息             |
1275| -------- | ------------------- |
1276| 12300001 | System service exception. |
1277| 12300002 | Invalid localId or photo.    |
1278| 12300003 | Account not found. |
1279| 12300008 | Restricted Account. |
1280
1281**示例:** 给ID为100的系统帐号设置头像
1282
1283  ```ts
1284  import { BusinessError } from '@ohos.base';
1285  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1286  let localId: number = 100;
1287  let photo: string = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAPCAYAAAA/I0V3AAAAAXNSR0IArs4c6QAAAARnQU1BAA'+
1288  'Cxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACwSURBVDhPvZLBDYMwDEV/ugsXRjAT0EHCOuFIBwkbdIRewi6unbiAyoGgSn1SFH85+Y'+
1289  'q/4ljARW62X+LHS8uIzjm4dXUYF+utzBikB52Jo5e5iEPKqpACk7R9NM2RvWm5tIkD2czLCUFNKLD6IjdMHFHDzws285MgGrT0xCtp3WOKHo'+
1290  '+7q0mP0DZW9pNmoEFUzrQjp5cCnaen2kSJXLFD8ghbXyZCMQf/8e8Ns1XVAG/XAgqKzVnJFAAAAABJRU5ErkJggg=='
1291  try {
1292    accountManager.setOsAccountProfilePhoto(localId, photo).then(() => {
1293      console.log('setOsAccountProfilePhoto success');
1294    }).catch((err: BusinessError) => {
1295      console.log('setOsAccountProfilePhoto err: ' + JSON.stringify(err));
1296    });
1297  } catch (e) {
1298    console.log('setOsAccountProfilePhoto exception: ' + JSON.stringify(e));
1299  }
1300  ```
1301
1302### on
1303
1304on(type: 'activate' | 'activating', name: string, callback: Callback&lt;number&gt;): void
1305
1306订阅系统帐号的激活完成与激活中的事件。使用callback异步回调。
1307
1308**系统接口:** 此接口为系统接口。
1309
1310**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1311
1312**系统能力:** SystemCapability.Account.OsAccount
1313
1314**参数:**
1315
1316| 参数名   | 类型                       | 必填 | 说明                                                         |
1317| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1318| type     | 'activate' \| 'activating' | 是   | 订阅类型,activate表示订阅的是帐号已激活完成的事件,activating表示订阅的是帐号正在激活的事件。 |
1319| name     | string                     | 是   | 订阅名称,可自定义,要求非空且长度不超过1024字节。           |
1320| callback | Callback&lt;number&gt;     | 是   | 订阅系统帐号激活完成与激活中的事件回调,表示激活完成后或正在激活中的系统帐号ID。    |
1321
1322**错误码:**
1323
1324| 错误码ID | 错误信息       |
1325| -------- | ------------- |
1326| 12300001 | System service exception. |
1327| 12300002 | Invalid type or name. |
1328
1329**示例:**
1330
1331  ```ts
1332  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1333  function onCallback(receiveLocalId: number){
1334    console.log('receive localId:' + receiveLocalId);
1335  }
1336  try {
1337    accountManager.on('activating', 'osAccountOnOffNameA', onCallback);
1338  } catch (e) {
1339    console.log('receive localId exception: ' + JSON.stringify(e));
1340  }
1341  ```
1342
1343### off
1344
1345off(type: 'activate' | 'activating', name: string, callback?: Callback&lt;number&gt;): void
1346
1347取消订阅系统帐号的激活完成与激活中的事件。使用callback异步回调。
1348
1349**系统接口:** 此接口为系统接口。
1350
1351**需要权限:** ohos.permission.INTERACT_ACROSS_LOCAL_ACCOUNTS_EXTENSION
1352
1353**系统能力:** SystemCapability.Account.OsAccount
1354
1355**参数:**
1356
1357| 参数名   | 类型                       | 必填 | 说明                                                         |
1358| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1359| type     | 'activate' \| 'activating' | 是   | 取消订阅类型,activate表示取消订阅帐号已激活完成的事件,activating取消订阅帐号正在激活的事件。 |
1360| name     | string                     | 是   | 订阅名称,可自定义,要求非空且长度不超过1024字节,需要与订阅接口传入的值保持一致。 |
1361| callback | Callback&lt;number&gt;     | 否   | 取消订阅系统帐号激活完成与激活中的事件回调,默认为空,表示取消该类型事件的所有回调。                      |
1362
1363**错误码:**
1364
1365| 错误码ID | 错误信息       |
1366| -------- | ------------- |
1367| 12300001 | System service exception. |
1368| 12300002 | Invalid type or name. |
1369
1370**示例:**
1371
1372  ```ts
1373  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1374  function offCallback(){
1375    console.log('off enter')
1376  }
1377  try {
1378    accountManager.off('activating', 'osAccountOnOffNameA', offCallback);
1379  } catch (e) {
1380    console.log('off exception: ' + JSON.stringify(e));
1381  }
1382  ```
1383
1384### getBundleIdForUid<sup>9+</sup>
1385
1386getBundleIdForUid(uid: number, callback: AsyncCallback&lt;number&gt;): void
1387
1388通过uid查询对应的bundleId,使用callback异步回调。
1389
1390**系统接口:** 此接口为系统接口。
1391
1392**系统能力:** SystemCapability.Account.OsAccount
1393
1394**参数:**
1395
1396| 参数名   | 类型                       | 必填 | 说明                                                                        |
1397| -------- | --------------------------- | ---- | ------------------------------------------------------------------------ |
1398| uid      | number                      | 是   | 进程uid。                                                                 |
1399| callback | AsyncCallback&lt;number&gt; | 是   | 回调函数。如果查询成功,err为null,data为与uid对应的bundleId;否则为错误对象。 |
1400
1401**错误码:**
1402
1403| 错误码ID | 错误信息       |
1404| -------- | ------------- |
1405| 12300001 | System service exception. |
1406| 12300002 | Invalid uid. |
1407
1408**示例:**
1409
1410  ```ts
1411  import { BusinessError } from '@ohos.base';
1412  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1413  let testUid: number = 1000000;
1414  try {
1415    accountManager.getBundleIdForUid(testUid, (err: BusinessError, bundleId: number) => {
1416      console.info('getBundleIdForUid errInfo:' + JSON.stringify(err));
1417      console.info('getBundleIdForUid bundleId:' + JSON.stringify(bundleId));
1418    });
1419  } catch (e) {
1420    console.info('getBundleIdForUid exception: ' + JSON.stringify(e));
1421  }
1422  ```
1423
1424### getBundleIdForUid<sup>9+</sup>
1425
1426getBundleIdForUid(uid: number): Promise&lt;number&gt;
1427
1428通过uid查询对应的bundleId,使用Promise异步回调。
1429
1430**系统接口:** 此接口为系统接口。
1431
1432**系统能力:** SystemCapability.Account.OsAccount
1433
1434**参数:**
1435
1436| 参数名  | 类型   | 必填 | 说明         |
1437| ------- | ------ | ---- | ------------ |
1438| uid     | number | 是   |  进程uid。 |
1439
1440**返回值:**
1441
1442| 类型                  | 说明                                  |
1443| --------------------- | ------------------------------------ |
1444| Promise&lt;number&gt; | Promise对象,返回与uid对应的bundleId。 |
1445
1446**错误码:**
1447
1448| 错误码ID | 错误信息       |
1449| -------- | ------------- |
1450| 12300001 | System service exception. |
1451| 12300002 | Invalid uid. |
1452
1453**示例:**
1454
1455  ```ts
1456  import { BusinessError } from '@ohos.base';
1457  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1458  let testUid: number = 1000000;
1459  try {
1460    accountManager.getBundleIdForUid(testUid).then((result: number) => {
1461      console.info('getBundleIdForUid bundleId:' + JSON.stringify(result));
1462    }).catch((err: BusinessError) => {
1463      console.info('getBundleIdForUid errInfo:' + JSON.stringify(err));
1464    });
1465  } catch (e) {
1466    console.info('getBundleIdForUid exception: ' + JSON.stringify(e));
1467  }
1468  ```
1469
1470### getBundleIdForUidSync<sup>10+</sup>
1471
1472getBundleIdForUidSync(uid: number): number
1473
1474通过uid查询对应的bundleId。使用同步方式返回结果。
1475
1476**系统接口:** 此接口为系统接口。
1477
1478**系统能力:** SystemCapability.Account.OsAccount
1479
1480**参数:**
1481
1482| 参数名  | 类型   | 必填 | 说明         |
1483| ------- | ------ | ---- | ------------ |
1484| uid     | number | 是   |  进程uid。 |
1485
1486**返回值:**
1487
1488| 类型   | 说明                     |
1489| ------ | ------------------------ |
1490| number | 表示与进程uid对应的bundleId。 |
1491
1492**错误码:**
1493
1494| 错误码ID | 错误信息       |
1495| -------- | ------------- |
1496| 12300002 | Invalid uid. |
1497
1498**示例:**
1499
1500  ```ts
1501  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1502  let testUid: number = 1000000;
1503  try {
1504    let bundleId : number = accountManager.getBundleIdForUidSync(testUid);
1505    console.info('getBundleIdForUidSync bundleId:' + bundleId);
1506  } catch (e) {
1507    console.info('getBundleIdForUidSync exception: ' + JSON.stringify(e));
1508  }
1509  ```
1510
1511### isMainOsAccount<sup>9+</sup>
1512
1513isMainOsAccount(callback: AsyncCallback&lt;boolean&gt;): void;
1514
1515查询当前进程是否处于主用户,使用callback异步回调。
1516
1517**系统接口:** 此接口为系统接口。
1518
1519**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1520
1521**系统能力:** SystemCapability.Account.OsAccount
1522
1523**参数:**
1524
1525| 参数名   | 类型                          | 必填 | 说明                                                               |
1526| -------- | ---------------------------- | ---- | ----------------------------------------------------------------- |
1527| callback | AsyncCallback&lt;boolean&gt; | 是   | 回调函数,返回true表示当前帐号为主帐号,返回false表示当前帐号非主帐号。 |
1528
1529**错误码:**
1530
1531| 错误码ID | 错误信息       |
1532| -------- | ------------- |
1533| 12300001 | System service exception. |
1534
1535**示例:**
1536
1537  ```ts
1538  import { BusinessError } from '@ohos.base';
1539  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1540  try {
1541    accountManager.isMainOsAccount((err: BusinessError,result: boolean)=>{
1542      console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
1543      console.info('isMainOsAccount result:' + JSON.stringify(result));
1544    });
1545  } catch (e) {
1546    console.info('isMainOsAccount exception: ' + JSON.stringify(e));
1547  }
1548  ```
1549
1550### isMainOsAccount<sup>9+</sup>
1551
1552isMainOsAccount(): Promise&lt;boolean&gt;;
1553
1554查询当前进程是否处于主用户,使用Promise异步回调。
1555
1556**系统接口:** 此接口为系统接口。
1557
1558**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1559
1560**系统能力:** SystemCapability.Account.OsAccount
1561
1562**返回值:**
1563
1564| 类型                   | 说明                                                                  |
1565| ---------------------- | --------------------------------------------------------------------- |
1566| Promise&lt;boolean&gt; | Promise对象,返回true表示当前帐号为主帐号,返回false表示当前帐号非主帐号。 |
1567
1568**错误码:**
1569
1570| 错误码ID | 错误信息       |
1571| -------- | ------------- |
1572| 12300001 | System service exception. |
1573
1574**示例:**
1575
1576  ```ts
1577  import { BusinessError } from '@ohos.base';
1578  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1579  try {
1580    accountManager.isMainOsAccount().then((result: boolean) => {
1581      console.info('isMainOsAccount result:' + JSON.stringify(result));
1582    }).catch((err: BusinessError) => {
1583      console.info('isMainOsAccount errInfo:' + JSON.stringify(err));
1584    });
1585  } catch (e) {
1586    console.info('isMainOsAccount exception: ' + JSON.stringify(e));
1587  }
1588  ```
1589
1590### getOsAccountConstraintSourceTypes<sup>9+</sup>
1591
1592getOsAccountConstraintSourceTypes(localId: number, constraint: string, callback: AsyncCallback&lt;Array&lt;ConstraintSourceTypeInfo&gt;&gt;): void;
1593
1594查询指定系统帐号的指定约束来源信息,使用callback异步回调。
1595
1596**系统接口:** 此接口为系统接口。
1597
1598**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1599
1600**系统能力:** SystemCapability.Account.OsAccount
1601
1602**参数:**
1603
1604| 参数名   | 类型                       | 必填 | 说明                                                         |
1605| -------- | -------------------------- | ---- | ------------------------------------------------------------ |
1606| localId     | number | 是   |  要查询的系统帐号ID |
1607| constraint     | string | 是   |  要查询的[约束](js-apis-osAccount.md#系统帐号约束列表)名称 |
1608| callback | AsyncCallback&lt;Array&lt;[ConstraintSourceTypeInfo](#constraintsourcetypeinfo9)&gt;&gt;     | 是   | 回调函数。如果成功,err为null,data为指定系统帐号的指定[约束](js-apis-osAccount.md#系统帐号约束列表)来源信息;否则为错误对象。                      |
1609
1610**错误码:**
1611
1612| 错误码ID | 错误信息       |
1613| -------- | ------------- |
1614| 12300001 | System service exception. |
1615| 12300002 | Invalid name or constraint. |
1616| 12300003 | Account not found. |
1617
1618**示例:**
1619
1620  ```ts
1621  import { BusinessError } from '@ohos.base';
1622  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1623  try {
1624    accountManager.getOsAccountConstraintSourceTypes(100, 'constraint.wifi',
1625      (err: BusinessError,sourceTypeInfos: account_osAccount.ConstraintSourceTypeInfo[])=>{
1626      console.info('getOsAccountConstraintSourceTypes errInfo:' + JSON.stringify(err));
1627      console.info('getOsAccountConstraintSourceTypes sourceTypeInfos:' + JSON.stringify(sourceTypeInfos));
1628    });
1629  } catch (e) {
1630    console.info('getOsAccountConstraintSourceTypes exception: ' + JSON.stringify(e));
1631  }
1632  ```
1633
1634### getOsAccountConstraintSourceTypes<sup>9+</sup>
1635
1636getOsAccountConstraintSourceTypes(localId: number, constraint: string): Promise&lt;Array&lt;ConstraintSourceTypeInfo&gt;&gt;;
1637
1638查询指定系统帐号的指定约束来源信息,使用Promise异步回调。
1639
1640**系统接口:** 此接口为系统接口。
1641
1642**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
1643
1644**系统能力:** SystemCapability.Account.OsAccount
1645
1646**参数:**
1647
1648| 参数名  | 类型   | 必填 | 说明         |
1649| ------- | ------ | ---- | ------------ |
1650| localId     | number | 是   |  要查询的系统帐号ID |
1651| constraint     | string | 是   |  要查询的[约束](js-apis-osAccount.md#系统帐号约束列表)名称 |
1652
1653**返回值:**
1654
1655| 类型                  | 说明                                                         |
1656| --------------------- | ------------------------------------------------------------ |
1657| Promise&lt;Array&lt;[ConstraintSourceTypeInfo](#constraintsourcetypeinfo9)&gt;&gt; | Promise对象,返回指定系统帐号的指定[约束](js-apis-osAccount.md#系统帐号约束列表)来源信息。 |
1658
1659**错误码:**
1660
1661| 错误码ID | 错误信息       |
1662| -------- | ------------- |
1663| 12300001 | System service exception. |
1664| 12300002 | Invalid name or constraint. |
1665| 12300003 | Account not found. |
1666
1667**示例:**
1668
1669  ```ts
1670  import { BusinessError } from '@ohos.base';
1671  let accountManager: account_osAccount.AccountManager = account_osAccount.getAccountManager();
1672  try {
1673    accountManager.getOsAccountConstraintSourceTypes(100, 'constraint.wifi').then(
1674      (result: account_osAccount.ConstraintSourceTypeInfo[]) => {
1675      console.info('getOsAccountConstraintSourceTypes sourceTypeInfos:' + JSON.stringify(result));
1676    }).catch((err: BusinessError) => {
1677      console.info('getOsAccountConstraintSourceTypes errInfo:' + JSON.stringify(err));
1678    });
1679  } catch (e) {
1680    console.info('getOsAccountConstraintSourceTypes exception: ' + JSON.stringify(e));
1681  }
1682  ```
1683
1684## UserAuth<sup>8+</sup>
1685
1686用户认证类。
1687
1688**系统接口:** 此接口为系统接口。
1689
1690### constructor<sup>8+</sup>
1691
1692constructor()
1693
1694创建用户认证的实例。
1695
1696**系统接口:** 此接口为系统接口。
1697
1698**系统能力**:SystemCapability.Account.OsAccount
1699
1700**示例:**
1701  ```ts
1702  let userAuth = new account_osAccount.UserAuth();
1703  ```
1704
1705### getVersion<sup>8+</sup>
1706
1707getVersion(): number;
1708
1709返回版本信息。
1710
1711**系统接口:** 此接口为系统接口。
1712
1713**系统能力:** SystemCapability.Account.OsAccount
1714
1715**返回值:**
1716
1717| 类型   | 说明         |
1718| :----- | :----------- |
1719| number | 返回版本信息。|
1720
1721**示例:**
1722  ```ts
1723  let userAuth = new account_osAccount.UserAuth();
1724  let version: number = userAuth.getVersion();
1725  console.log('getVersion version = ' + version);
1726  ```
1727
1728### getAvailableStatus<sup>8+</sup>
1729
1730getAvailableStatus(authType: AuthType, authTrustLevel: AuthTrustLevel): number;
1731
1732获取指定认证类型和认证可信等级的认证能力的可用状态。
1733
1734**系统接口:** 此接口为系统接口。
1735
1736**系统能力:** SystemCapability.Account.OsAccount
1737
1738**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
1739
1740**参数:**
1741
1742| 参数名           | 类型                               | 必填 | 说明                       |
1743| --------------- | -----------------------------------| ---- | ------------------------- |
1744| authType        | [AuthType](#authtype8)             | 是   | 认证类型。     |
1745| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8) | 是   | 认证的可信等级。 |
1746
1747**返回值:**
1748
1749| 类型   | 说明                           |
1750| ------ | ----------------------------- |
1751| number | 返回认证能力的可用状态。 |
1752
1753**错误码:**
1754
1755| 错误码ID | 错误信息                     |
1756| -------- | --------------------------- |
1757| 12300001 | System service exception. |
1758| 12300002 | Invalid authType or authTrustLevel. |
1759
1760**示例:**
1761  ```ts
1762  let userAuth = new account_osAccount.UserAuth();
1763  let authType: account_osAccount.AuthType = account_osAccount.AuthType.PIN;
1764  let authTrustLevel: account_osAccount.AuthTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
1765  try {
1766    let status: number = userAuth.getAvailableStatus(authType, authTrustLevel);
1767    console.log('getAvailableStatus status = ' + status);
1768  } catch (e) {
1769    console.log('getAvailableStatus exception = ' + JSON.stringify(e));
1770  }
1771  ```
1772
1773### getProperty<sup>8+</sup>
1774
1775getProperty(request: GetPropertyRequest, callback: AsyncCallback&lt;ExecutorProperty&gt;): void;
1776
1777基于指定的请求信息获取属性。使用callback异步回调。
1778
1779**系统接口:** 此接口为系统接口。
1780
1781**系统能力:** SystemCapability.Account.OsAccount
1782
1783**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
1784
1785**参数:**
1786
1787| 参数名    | 类型                                                                    | 必填 | 说明                                |
1788| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------ |
1789| request  | [GetPropertyRequest](#getpropertyrequest8)                  | 是   | 请求信息,包括认证类型和属性类型列表。 |
1790| callback | AsyncCallback&lt;[ExecutorProperty](#executorproperty8)&gt; | 是   | 回调函数。如果获取成功,err为null,data为执行器属性信息;否则为错误对象。|
1791
1792**错误码:**
1793
1794| 错误码ID | 错误信息                     |
1795| -------- | --------------------------- |
1796| 12300001 | System service exception. |
1797| 12300002 | Invalid request. |
1798
1799**示例:**
1800  ```ts
1801  import { BusinessError } from '@ohos.base';
1802  let userAuth = new account_osAccount.UserAuth();
1803  let keys: Array<account_osAccount.GetPropertyType>  = [
1804    account_osAccount.GetPropertyType.AUTH_SUB_TYPE,
1805    account_osAccount.GetPropertyType.REMAIN_TIMES,
1806    account_osAccount.GetPropertyType.FREEZING_TIME
1807  ];
1808  let request: account_osAccount.GetPropertyRequest = {
1809    authType: account_osAccount.AuthType.PIN,
1810    keys: keys
1811  };
1812  try {
1813    userAuth.getProperty(request, (err: BusinessError, result: account_osAccount.ExecutorProperty) => {
1814      console.log('getProperty err = ' + JSON.stringify(err));
1815      console.log('getProperty result = ' + JSON.stringify(result));
1816    });
1817  } catch (e) {
1818    console.log('getProperty exception = ' + JSON.stringify(e));
1819  }
1820  ```
1821
1822### getProperty<sup>8+</sup>
1823
1824getProperty(request: GetPropertyRequest): Promise&lt;ExecutorProperty&gt;;
1825
1826基于指定的请求信息获取属性。使用Promise异步回调。
1827
1828**系统接口:** 此接口为系统接口。
1829
1830**系统能力:** SystemCapability.Account.OsAccount
1831
1832**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
1833
1834**参数:**
1835
1836| 参数名    | 类型                                                   | 必填 | 说明                                |
1837| -------- | ------------------------------------------------------ | ---- | ---------------------------------- |
1838| request  | [GetPropertyRequest](#getpropertyrequest8) | 是   | 请求信息,包括认证类型和属性类型列表。 |
1839
1840**返回值:**
1841
1842| 类型                                                              | 说明                                                 |
1843| :---------------------------------------------------------------- | :-------------------------------------------------- |
1844| Promise&lt;[ExecutorProperty](#executorproperty8)&gt; | Promise对象,返回执行者属性信息。 |
1845
1846**错误码:**
1847
1848| 错误码ID | 错误信息                     |
1849| -------- | --------------------------- |
1850| 12300001 | System service exception. |
1851| 12300002 | Invalid request. |
1852
1853**示例:**
1854  ```ts
1855  import { BusinessError } from '@ohos.base';
1856  let userAuth = new account_osAccount.UserAuth();
1857  let keys: Array<account_osAccount.GetPropertyType> = [
1858    account_osAccount.GetPropertyType.AUTH_SUB_TYPE,
1859    account_osAccount.GetPropertyType.REMAIN_TIMES,
1860    account_osAccount.GetPropertyType.FREEZING_TIME
1861  ];
1862  let request: account_osAccount.GetPropertyRequest = {
1863    authType: account_osAccount.AuthType.PIN,
1864    keys: keys
1865  };
1866  try {
1867    userAuth.getProperty(request).then((result: account_osAccount.ExecutorProperty) => {
1868      console.log('getProperty result = ' + JSON.stringify(result));
1869    }).catch((err: BusinessError) => {
1870      console.log('getProperty error = ' + JSON.stringify(err));
1871    });
1872  } catch (e) {
1873    console.log('getProperty exception = ' + JSON.stringify(e));
1874  }
1875  ```
1876
1877### setProperty<sup>8+</sup>
1878
1879setProperty(request: SetPropertyRequest, callback: AsyncCallback&lt;void&gt;): void;
1880
1881设置可用于初始化算法的属性。使用callback异步回调。
1882
1883**系统接口:** 此接口为系统接口。
1884
1885**系统能力:** SystemCapability.Account.OsAccount
1886
1887**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
1888
1889**参数:**
1890
1891| 参数名    | 类型                                                  | 必填 | 说明                                                                    |
1892| -------- | ----------------------------------------------------- | ---- | ---------------------------------------------------------------------- |
1893| request  | [SetPropertyRequest](#setpropertyrequest8)| 是   | 请求信息,包括认证类型和要设置的密钥值。                                   |
1894| callback | AsyncCallback&lt;void&gt;                           | 是   | 回调函数。如果设置成功,err为null,否则为错误对象。 |
1895
1896**错误码:**
1897
1898| 错误码ID | 错误信息                     |
1899| -------- | --------------------------- |
1900| 12300001 | System service exception. |
1901| 12300002 | Invalid request. |
1902
1903**示例:**
1904  ```ts
1905  import { BusinessError } from '@ohos.base';
1906  let userAuth = new account_osAccount.UserAuth();
1907  let request: account_osAccount.SetPropertyRequest = {
1908    authType: account_osAccount.AuthType.PIN,
1909    key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
1910    setInfo: new Uint8Array([0])
1911  };
1912  try {
1913    userAuth.setProperty(request, (err: BusinessError) => {
1914      if (err) {
1915        console.log('setProperty failed, error = ' + JSON.stringify(err));
1916      } else {
1917        console.log('setProperty successfully');
1918      }
1919    });
1920  } catch (e) {
1921    console.log('setProperty exception = ' + JSON.stringify(e));
1922  }
1923  ```
1924
1925### setProperty<sup>8+</sup>
1926
1927setProperty(request: SetPropertyRequest): Promise&lt;void&gt;;
1928
1929设置可用于初始化算法的属性。使用Promise异步回调。
1930
1931**系统接口:** 此接口为系统接口。
1932
1933**系统能力:** SystemCapability.Account.OsAccount
1934
1935**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
1936
1937**参数:**
1938
1939| 参数名    | 类型                                       | 必填 | 说明                                      |
1940| -------- | ------------------------------------------ | ---- | ---------------------------------------- |
1941| request  | [SetPropertyRequest](#setpropertyrequest8) | 是   | 请求信息,包括身份验证类型和要设置的密钥值。 |
1942
1943**返回值:**
1944
1945| 类型                  | 说明                                                           |
1946| :-------------------- | :------------------------------------------------------------ |
1947| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
1948
1949**错误码:**
1950
1951| 错误码ID | 错误信息                     |
1952| -------- | --------------------------- |
1953| 12300001 | System service exception. |
1954| 12300002 | Invalid request. |
1955
1956**示例:**
1957  ```ts
1958  import { BusinessError } from '@ohos.base';
1959  let userAuth = new account_osAccount.UserAuth();
1960  let request: account_osAccount.SetPropertyRequest = {
1961    authType: account_osAccount.AuthType.PIN,
1962    key: account_osAccount.SetPropertyType.INIT_ALGORITHM,
1963    setInfo: new Uint8Array([0])
1964  };
1965  try {
1966    userAuth.setProperty(request).then(() => {
1967      console.log('setProperty successfully');
1968    }).catch((err: BusinessError) => {
1969      console.log('setProperty failed, error = ' + JSON.stringify(err));
1970    });
1971  } catch (e) {
1972    console.log('setProperty exception = ' + JSON.stringify(e));
1973  }
1974  ```
1975
1976### auth<sup>8+</sup>
1977
1978auth(challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
1979
1980认证当前用户。使用callback异步回调。
1981
1982**系统接口:** 此接口为系统接口。
1983
1984**系统能力:** SystemCapability.Account.OsAccount
1985
1986**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
1987
1988**参数:**
1989
1990| 参数名           | 类型                                     | 必填 | 说明                                |
1991| --------------- | ---------------------------------------- | --- | ------------------------------------ |
1992| challenge       | Uint8Array                               | 是  | 指示挑战值,挑战值为一个随机数,用于提升安全性。|
1993| authType        | [AuthType](#authtype8)                   | 是  | 指示认证类型。                        |
1994| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8)       | 是  | 指示认证结果的信任级别。               |
1995| callback        | [IUserAuthCallback](#iuserauthcallback8) | 是  | 回调对象,返回认证结果。  |
1996
1997**返回值:**
1998
1999| 类型        | 说明               |
2000| ---------- | ------------------ |
2001| Uint8Array | 返回取消的上下文ID。 |
2002
2003**错误码:**
2004
2005| 错误码ID | 错误信息          |
2006| -------- | --------------------- |
2007| 12300001 | System service exception. |
2008| 12300002 | Invalid challenge, authType or authTrustLevel. |
2009| 12300101 | Credential is incorrect. |
2010| 12300102 | Credential not enrolled. |
2011| 12300105 | Unsupported authTrustLevel. |
2012| 12300106 | Unsupported authType. |
2013| 12300109 | Authentication is canceled. |
2014| 12300110 | Authentication is locked. |
2015| 12300111 | Authentication timeout. |
2016| 12300112 | Authentication service is busy. |
2017
2018**示例:**
2019  ```ts
2020  let userAuth = new account_osAccount.UserAuth();
2021  let challenge: Uint8Array = new Uint8Array([0]);
2022  let authType: account_osAccount.AuthType = account_osAccount.AuthType.PIN;
2023  let authTrustLevel: account_osAccount.AuthTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
2024  try {
2025    userAuth.auth(challenge, authType, authTrustLevel, {
2026      onResult: (result: number, extraInfo: account_osAccount.AuthResult) => {
2027          console.log('auth result = ' + result);
2028          console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
2029      }
2030    });
2031  } catch (e) {
2032    console.log('auth exception = ' + JSON.stringify(e));
2033  }
2034  ```
2035
2036### authUser<sup>8+</sup>
2037
2038authUser(userId: number, challenge: Uint8Array, authType: AuthType, authTrustLevel: AuthTrustLevel, callback: IUserAuthCallback): Uint8Array;
2039
2040认证指定用户。使用callback异步回调。
2041
2042**系统接口:** 此接口为系统接口。
2043
2044**系统能力:** SystemCapability.Account.OsAccount
2045
2046**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2047
2048**参数:**
2049
2050| 参数名           | 类型                                                 | 必填 | 说明                                |
2051| --------------- | ---------------------------------------------------- | --- | ------------------------------------ |
2052| userId          | number                                               | 是  | 指示用户身份。                        |
2053| challenge       | Uint8Array                                           | 是  | 指示挑战值,挑战值为一个随机数,用于提升安全性。                          |
2054| authType        | [AuthType](#authtype8)                   | 是  | 指示认证类型。                        |
2055| authTrustLevel  | [AuthTrustLevel](#authtrustlevel8)       | 是  | 指示认证结果的信任级别。               |
2056| callback        | [IUserAuthCallback](#iuserauthcallback8) | 是  | 回调对象,返回认证结果。  |
2057
2058**返回值:**
2059
2060| 类型        | 说明               |
2061| ---------- | ------------------ |
2062| Uint8Array | 返回取消的上下文ID。 |
2063
2064**错误码:**
2065
2066| 错误码ID | 错误信息          |
2067| -------- | --------------------- |
2068| 12300001 | System service exception. |
2069| 12300002 | Invalid userId, challenge, authType or authTrustLevel. |
2070| 12300101 | Credential is incorrect. |
2071| 12300102 | Credential not enrolled. |
2072| 12300105 | Unsupported authTrustLevel. |
2073| 12300106 | Unsupported authType. |
2074| 12300109 | Authentication is canceled. |
2075| 12300110 | Authentication is locked. |
2076| 12300111 | Authentication timeout. |
2077| 12300112 | Authentication service is busy. |
2078
2079**示例:**
2080  ```ts
2081  let userAuth = new account_osAccount.UserAuth();
2082  let userID: number = 100;
2083  let challenge: Uint8Array = new Uint8Array([0]);
2084  let authType: account_osAccount.AuthType = account_osAccount.AuthType.PIN;
2085  let authTrustLevel: account_osAccount.AuthTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
2086  try {
2087    userAuth.authUser(userID, challenge, authType, authTrustLevel, {
2088      onResult: (result,extraInfo) => {
2089        console.log('authUser result = ' + result);
2090        console.log('authUser extraInfo = ' + JSON.stringify(extraInfo));
2091      }
2092    });
2093  } catch (e) {
2094    console.log('authUser exception = ' + JSON.stringify(e));
2095  }
2096  ```
2097
2098### cancelAuth<sup>8+</sup>
2099
2100cancelAuth(contextID: Uint8Array): void;
2101
2102取消指定的认证操作。
2103
2104**系统接口:** 此接口为系统接口。
2105
2106**系统能力:** SystemCapability.Account.OsAccount
2107
2108**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2109
2110**参数:**
2111
2112| 参数名    | 类型       | 必填  | 说明                                        |
2113| ----------| ---------- | ---- | ------------------------------------------ |
2114| contextId | Uint8Array | 是   | 指示身份验证上下文ID,此ID动态生成没有具体值。 |
2115
2116**错误码:**
2117
2118| 错误码ID | 错误信息            |
2119| -------- | ------------------ |
2120| 12300001 | System service exception. |
2121| 12300002 | Invalid contextId. |
2122
2123**示例:**
2124  ```ts
2125  let userAuth = new account_osAccount.UserAuth();
2126  let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
2127  let challenge = new Uint8Array([0]);
2128  let contextId: Uint8Array = userAuth.auth(challenge, account_osAccount.AuthType.PIN, account_osAccount.AuthTrustLevel.ATL1, {
2129    onResult: (result: number, extraInfo: account_osAccount.AuthResult) => {
2130      console.log('auth result = ' + result);
2131      console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
2132    }
2133  });
2134  try {
2135    userAuth.cancelAuth(contextId);
2136  } catch (e) {
2137    console.log('cancelAuth exception = ' + JSON.stringify(e));
2138  }
2139  ```
2140
2141## PINAuth<sup>8+</sup>
2142
2143PIN码认证基类。
2144
2145**系统接口:** 此接口为系统接口。
2146
2147### constructor<sup>8+</sup>
2148
2149constructor()
2150
2151创建PIN码认证的实例。
2152
2153**系统接口:** 此接口为系统接口。
2154
2155**系统能力**:SystemCapability.Account.OsAccount
2156
2157**示例:**
2158  ```ts
2159  let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
2160  ```
2161
2162### registerInputer<sup>8+</sup>
2163
2164registerInputer(inputer: IInputer): void;
2165
2166注册PIN码输入器。
2167
2168**系统接口:** 此接口为系统接口。
2169
2170**系统能力:** SystemCapability.Account.OsAccount
2171
2172**需要权限:** ohos.permission.ACCESS_PIN_AUTH
2173
2174**参数:**
2175
2176| 参数名    | 类型                     | 必填 | 说明                      |
2177| ----------| ----------------------- | --- | -------------------------- |
2178| inputer   | [IInputer](#iinputer8)  | 是  | PIN码输入器,用于获取PIN码。 |
2179
2180**错误码:**
2181
2182| 错误码ID | 错误信息                     |
2183| -------- | --------------------------- |
2184| 12300001 | System service exception. |
2185| 12300002 | Invalid inputer. |
2186| 12300103 | Inputer already registered. |
2187
2188**示例:**
2189  ```ts
2190  let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
2191  let password = new Uint8Array([0, 0, 0, 0, 0]);
2192  try {
2193    pinAuth.registerInputer({
2194        onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
2195          callback.onSetData(authSubType, password);
2196        }
2197    });
2198    console.log('registerInputer success.');
2199  } catch (e) {
2200    console.log('registerInputer exception = ' + JSON.stringify(e));
2201  }
2202  ```
2203
2204### unregisterInputer<sup>8+</sup>
2205
2206unregisterInputer(): void;
2207
2208解注册PIN码输入器。
2209
2210**系统接口:** 此接口为系统接口。
2211
2212**系统能力:** SystemCapability.Account.OsAccount
2213
2214**需要权限:** ohos.permission.ACCESS_PIN_AUTH
2215
2216**示例:**
2217  ```ts
2218  let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
2219  pinAuth.unregisterInputer();
2220  ```
2221
2222## InputerManager <sup>9+</sup>
2223
2224凭据输入管理器。
2225
2226### registerInputer<sup>9+</sup>
2227
2228static registerInputer(authType: AuthType, inputer: IInputer): void
2229
2230注册凭据输入器。
2231
2232**系统接口:** 此接口为系统接口。
2233
2234**系统能力:** SystemCapability.Account.OsAccount
2235
2236**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNALohos.permission.MANAGE_USER_IDM
2237
2238**参数:**
2239
2240| 参数名    | 类型                     | 必填 | 说明                      |
2241| ----------| ----------------------- | --- | -------------------------- |
2242| authType   | [AuthType](#authtype8)  | 是  | 认证类型。 |
2243| inputer   | [IInputer](#iinputer8)  | 是  | 凭据输入器,用于获取凭据。 |
2244
2245**错误码:**
2246
2247| 错误码ID | 错误信息                     |
2248| -------- | --------------------------- |
2249| 12300001 | System service exception. |
2250| 12300002 | Invalid authType or inputer. |
2251| 12300103 | The credential inputer has been registered. |
2252| 12300106 | Unsupported authType. |
2253
2254**示例:**
2255  ```ts
2256  let authType: account_osAccount.AuthType = account_osAccount.AuthType.DOMAIN;
2257  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0]);
2258  try {
2259    account_osAccount.InputerManager.registerInputer(authType, {
2260        onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
2261          callback.onSetData(authSubType, password);
2262        }
2263    });
2264    console.log('registerInputer success.');
2265  } catch (e) {
2266    console.log('registerInputer exception = ' + JSON.stringify(e));
2267  }
2268  ```
2269
2270### unregisterInputer<sup>9+</sup>
2271
2272static unregisterInputer(authType: AuthType): void
2273
2274解注册凭据输入器。
2275
2276**系统接口:** 此接口为系统接口。
2277
2278**系统能力:** SystemCapability.Account.OsAccount
2279
2280**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNALohos.permission.MANAGE_USER_IDM
2281
2282**参数:**
2283
2284| 参数名    | 类型                     | 必填 | 说明                      |
2285| ----------| ----------------------- | --- | -------------------------- |
2286| authType   | [AuthType](#authtype8)  | 是  | 认证类型。 |
2287
2288**错误码:**
2289
2290| 错误码ID | 错误信息                     |
2291| -------- | --------------------------- |
2292| 12300002  | Invalid authType. |
2293
2294**示例:**
2295  ```ts
2296  let authType: account_osAccount.AuthType = account_osAccount.AuthType.DOMAIN;
2297  try {
2298    account_osAccount.InputerManager.unregisterInputer(authType);
2299    console.log('unregisterInputer success.');
2300  } catch(err) {
2301    console.log('unregisterInputer err:' + JSON.stringify(err));
2302  }
2303  ```
2304
2305## DomainPlugin<sup>9+</sup>
2306
2307域插件,提供域帐号认证功能。
2308
2309**系统接口:** 此接口为系统接口。
2310
2311### auth<sup>9+</sup>
2312
2313auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUserAuthCallback): void
2314
2315认证指定的域帐号。
2316
2317**系统接口:** 此接口为系统接口。
2318
2319**系统能力:** SystemCapability.Account.OsAccount
2320
2321**参数:**
2322
2323| 参数名      | 类型                                    | 必填 | 说明             |
2324| ---------- | --------------------------------------- | ---- | --------------- |
2325| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
2326| credential   | Uint8Array  | 是   | 指示域帐号的凭据。|
2327| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
2328
2329**示例:**
2330  ```ts
2331  import { AsyncCallback } from '@ohos.base';
2332  let plugin: account_osAccount.DomainPlugin = {
2333    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2334          callback: account_osAccount.IUserAuthCallback) => {
2335      // mock authentication
2336      // notify authentication result
2337      let result: account_osAccount.AuthResult = {
2338        token: new Uint8Array([0]),
2339        remainTimes: 5,
2340        freezingTime: 0
2341      };
2342      callback.onResult(0, result);
2343    },
2344    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2345                    callback: account_osAccount.IUserAuthCallback) => {},
2346    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2347                    callback: account_osAccount.IUserAuthCallback) => {},
2348    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2349                    callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
2350    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2351                      callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
2352    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2353                  callback: AsyncCallback<void>) => {},
2354    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
2355    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2356                          callback: AsyncCallback<boolean>) => {},
2357    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
2358  }
2359  account_osAccount.DomainAccountManager.registerPlugin(plugin);
2360  let userAuth = new account_osAccount.UserAuth();
2361  let challenge: Uint8Array = new Uint8Array([0]);
2362  let authType: account_osAccount.AuthType = account_osAccount.AuthType.DOMAIN;
2363  let authTrustLevel: account_osAccount.AuthTrustLevel = account_osAccount.AuthTrustLevel.ATL1;
2364  try {
2365    userAuth.auth(challenge, authType, authTrustLevel, {
2366      onResult: (resultCode: number, authResult: account_osAccount.AuthResult) => {
2367          console.log('auth resultCode = ' + resultCode);
2368          console.log('auth authResult = ' + JSON.stringify(authResult));
2369      }
2370    });
2371  } catch (err) {
2372    console.log('auth exception = ' + JSON.stringify(err));
2373  }
2374  ```
2375
2376### authWithPopup<sup>10+</sup>
2377
2378authWithPopup(domainAccountInfo: DomainAccountInfo, callback: IUserAuthCallback): void
2379
2380弹窗认证指定的域帐号。
2381
2382**系统接口:** 此接口为系统接口。
2383
2384**系统能力:** SystemCapability.Account.OsAccount
2385
2386**参数:**
2387
2388| 参数名      | 类型                                    | 必填 | 说明             |
2389| ---------- | --------------------------------------- | ---- | --------------- |
2390| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
2391| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
2392
2393**示例:**
2394  ```ts
2395  import { AsyncCallback } from '@ohos.base';
2396  let plugin: account_osAccount.DomainPlugin = {
2397    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2398          callback: account_osAccount.IUserAuthCallback) => {},
2399    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2400                    callback: account_osAccount.IUserAuthCallback) => {
2401      // mock authentication
2402      // notify authentication result
2403      let result: account_osAccount.AuthResult = {
2404        token: new Uint8Array([0]),
2405        remainTimes: 5,
2406        freezingTime: 0
2407      };
2408      callback.onResult(0, result);
2409    },
2410    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2411                    callback: account_osAccount.IUserAuthCallback) => {},
2412    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2413                    callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
2414    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2415                        callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
2416    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2417                  callback: AsyncCallback<void>) => {},
2418    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
2419    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2420                          callback: AsyncCallback<boolean>) => {},
2421    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
2422  }
2423  account_osAccount.DomainAccountManager.registerPlugin(plugin)
2424  ```
2425
2426### authWithToken<sup>10+</sup>
2427
2428authWithToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: IUserAuthCallback): void
2429
2430使用授权令牌认证指定的域帐号。
2431
2432**系统接口:** 此接口为系统接口。
2433
2434**系统能力:** SystemCapability.Account.OsAccount
2435
2436**参数:**
2437
2438| 参数名      | 类型                                    | 必填 | 说明             |
2439| ---------- | --------------------------------------- | ---- | --------------- |
2440| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
2441| token   | Uint8Array  | 是   | 指示PIN码或生物识别认证成功时生成的授权令牌。|
2442| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
2443
2444**示例:**
2445  ```ts
2446  import { AsyncCallback } from '@ohos.base';
2447  let plugin: account_osAccount.DomainPlugin = {
2448    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2449          callback: account_osAccount.IUserAuthCallback) => {},
2450    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2451                    callback: account_osAccount.IUserAuthCallback) => {},
2452    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2453                    callback: account_osAccount.IUserAuthCallback) => {
2454      // mock authentication
2455      // notify authentication result
2456      let result: account_osAccount.AuthResult = {
2457        token: new Uint8Array([0]),
2458        remainTimes: 5,
2459        freezingTime: 0
2460      };
2461      callback.onResult(0, result);
2462    },
2463    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2464                    callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
2465    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2466                        callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
2467    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2468                  callback: AsyncCallback<void>) => {},
2469    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
2470    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2471                          callback: AsyncCallback<boolean>) => {},
2472    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
2473  }
2474  account_osAccount.DomainAccountManager.registerPlugin(plugin)
2475  ```
2476
2477### getAccountInfo<sup>10+</sup>
2478
2479getAccountInfo(options: GetDomainAccountInfoPluginOptions, callback: AsyncCallback&lt;DomainAccountInfo&gt;): void
2480
2481查询指定域帐号的信息。
2482
2483**系统接口:** 此接口为系统接口。
2484
2485**系统能力:** SystemCapability.Account.OsAccount
2486
2487**参数:**
2488
2489| 参数名      | 类型                                    | 必填 | 说明             |
2490| ---------- | --------------------------------------- | ---- | --------------- |
2491| options   | [GetDomainAccountInfoPluginOptions](#getdomainaccountinfopluginoptions10)  | 是   | 指示域帐号信息。|
2492| callback   | AsyncCallback&lt;[DomainAccountInfo](#domainaccountinfo8)&gt; | 是   | 指示查询结果回调。|
2493
2494**示例:**
2495  ```ts
2496  import { AsyncCallback, BusinessError } from '@ohos.base';
2497  let plugin: account_osAccount.DomainPlugin = {
2498    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2499          callback: account_osAccount.IUserAuthCallback) => {},
2500    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2501                    callback: account_osAccount.IUserAuthCallback) => {},
2502    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2503                    callback: account_osAccount.IUserAuthCallback) => {},
2504    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2505                    callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {
2506      // mock getting account information
2507      // notify result
2508      let code: BusinessError = {
2509        code: 0,
2510        name: "",
2511        message: ""
2512      };
2513      let accountInfo: account_osAccount.DomainAccountInfo = {
2514        domain: options.domain ? options.domain : "",
2515        accountName: options.accountName,
2516        accountId: 'xxxx'
2517      };
2518      callback(code, accountInfo);
2519    },
2520    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2521                        callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
2522    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2523                  callback: AsyncCallback<void>) => {},
2524    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
2525    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2526                          callback: AsyncCallback<boolean>) => {},
2527    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
2528  }
2529  account_osAccount.DomainAccountManager.registerPlugin(plugin)
2530  ```
2531
2532### getAuthStatusInfo<sup>10+</sup>
2533
2534getAuthStatusInfo(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback&lt;AuthStatusInfo&gt;): void
2535
2536查询指定域帐号的认证状态信息。
2537
2538**系统接口:** 此接口为系统接口。
2539
2540**系统能力:** SystemCapability.Account.OsAccount
2541
2542**参数:**
2543
2544| 参数名      | 类型                                    | 必填 | 说明             |
2545| ---------- | --------------------------------------- | ---- | --------------- |
2546| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
2547| callback   | AsyncCallback&lt;[AuthStatusInfo](#authstatusinfo10)&gt; | 是   | 指示查询结果回调。|
2548
2549**示例:**
2550  ```ts
2551  import { AsyncCallback, BusinessError } from '@ohos.base';
2552  let plugin: account_osAccount.DomainPlugin = {
2553    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2554          callback: account_osAccount.IUserAuthCallback) => {},
2555    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2556                    callback: account_osAccount.IUserAuthCallback) => {},
2557    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2558                    callback: account_osAccount.IUserAuthCallback) => {},
2559    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2560                    callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
2561    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2562                        callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {
2563      let code: BusinessError = {
2564        code: 0,
2565        name: "",
2566        message: ""
2567      };
2568      let statusInfo: account_osAccount.AuthStatusInfo = {
2569        remainTimes: 5,
2570        freezingTime: 0
2571      };
2572      callback(code, statusInfo);
2573    },
2574    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2575                  callback: AsyncCallback<void>) => {},
2576    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
2577    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2578                          callback: AsyncCallback<boolean>) => {},
2579    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
2580  }
2581  account_osAccount.DomainAccountManager.registerPlugin(plugin)
2582  ```
2583
2584### bindAccount<sup>10+</sup>
2585
2586bindAccount(domainAccountInfo: DomainAccountInfo, localId: number, callback: AsyncCallback&lt;void&gt;): void
2587
2588绑定指定的域帐号。
2589
2590**系统接口:** 此接口为系统接口。
2591
2592**系统能力:** SystemCapability.Account.OsAccount
2593
2594**参数:**
2595
2596| 参数名      | 类型                                    | 必填 | 说明             |
2597| ---------- | --------------------------------------- | ---- | --------------- |
2598| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
2599| callback   | AsyncCallback&lt;void&gt; | 是   | 指示绑定结果回调。|
2600
2601**示例:**
2602  ```ts
2603  import { AsyncCallback, BusinessError } from '@ohos.base';
2604  let plugin: account_osAccount.DomainPlugin = {
2605    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2606          callback: account_osAccount.IUserAuthCallback) => {},
2607    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2608                    callback: account_osAccount.IUserAuthCallback) => {},
2609    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2610                    callback: account_osAccount.IUserAuthCallback) => {},
2611    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2612                    callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
2613    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2614                        callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
2615    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2616                  callback: AsyncCallback<void>) => {
2617      // mock unbinding operation
2618      // notify binding result
2619      let code: BusinessError = {
2620        code: 0,
2621        name: "",
2622        message: ""
2623      };
2624      callback(code);
2625    },
2626    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
2627    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2628                          callback: AsyncCallback<boolean>) => {},
2629    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
2630  }
2631  account_osAccount.DomainAccountManager.registerPlugin(plugin)
2632  ```
2633
2634### unbindAccount<sup>10+</sup>
2635
2636unbindAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback&lt;void&gt;): void
2637
2638解绑指定的域帐号。
2639
2640**系统接口:** 此接口为系统接口。
2641
2642**系统能力:** SystemCapability.Account.OsAccount
2643
2644**参数:**
2645
2646| 参数名      | 类型                                    | 必填 | 说明             |
2647| ---------- | --------------------------------------- | ---- | --------------- |
2648| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
2649| callback   | AsyncCallback&lt;void&gt; | 是   | 指示绑定结果回调。|
2650
2651**示例:**
2652  ```ts
2653  import { AsyncCallback, BusinessError } from '@ohos.base';
2654  let plugin: account_osAccount.DomainPlugin = {
2655    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2656          callback: account_osAccount.IUserAuthCallback) => {},
2657    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2658                    callback: account_osAccount.IUserAuthCallback) => {},
2659    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2660                    callback: account_osAccount.IUserAuthCallback) => {},
2661    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2662                    callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
2663    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2664                        callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
2665    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2666                  callback: AsyncCallback<void>) => {},
2667    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {
2668      // mock unbinding operation
2669      // notify unbinding result
2670      let code: BusinessError = {
2671        code: 0,
2672        name: "",
2673        message: ""
2674      };
2675      callback(code);
2676    },
2677    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2678                          callback: AsyncCallback<boolean>) => {},
2679    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
2680  }
2681  account_osAccount.DomainAccountManager.registerPlugin(plugin)
2682  ```
2683
2684### isAccountTokenValid<sup>10+</sup>
2685
2686isAccountTokenValid(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: AsyncCallback&lt;boolean&gt;): void
2687
2688检查指定的域帐号令牌是否有效。
2689
2690**系统接口:** 此接口为系统接口。
2691
2692**系统能力:** SystemCapability.Account.OsAccount
2693
2694**参数:**
2695
2696| 参数名      | 类型                                    | 必填 | 说明             |
2697| ---------- | --------------------------------------- | ---- | --------------- |
2698| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
2699| token | Uint8Array | 是 | 指示域帐号令牌。 |
2700| callback   | AsyncCallback&lt;boolean&gt; | 是   | 指示检查结果回调。|
2701
2702**示例:**
2703  ```ts
2704  import { AsyncCallback, BusinessError } from '@ohos.base';
2705  let plugin: account_osAccount.DomainPlugin = {
2706    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2707          callback: account_osAccount.IUserAuthCallback) => {},
2708    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2709                    callback: account_osAccount.IUserAuthCallback) => {},
2710    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2711                    callback: account_osAccount.IUserAuthCallback) => {},
2712    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2713                    callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
2714    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2715                        callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
2716    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2717                  callback: AsyncCallback<void>) => {},
2718    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
2719    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2720                          callback: AsyncCallback<boolean>) => {
2721      // mock checking operation
2722      // notify checking result
2723      let code: BusinessError = {
2724        code: 0,
2725        name: "",
2726        message: ""
2727      };
2728      callback(code, true);
2729    },
2730    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
2731  }
2732  account_osAccount.DomainAccountManager.registerPlugin(plugin)
2733  ```
2734
2735### getAccessToken<sup>10+</sup>
2736
2737getAccessToken(options: GetDomainAccessTokenOptions, callback: AsyncCallback&lt;Uint8Array&gt;): void
2738
2739根据指定的选项获取域访问令牌。
2740
2741**系统接口:** 此接口为系统接口。
2742
2743**系统能力:** SystemCapability.Account.OsAccount
2744
2745**参数:**
2746
2747| 参数名      | 类型                                    | 必填 | 说明             |
2748| ---------- | --------------------------------------- | ---- | --------------- |
2749| options | [GetDomainAccessTokenOptions](#getdomainaccesstokenoptions10)  | 是   | 指示获取域访问令牌的选项。|
2750| callback   | AsyncCallback&lt;Uint8Array&gt; | 是   | 指示结果回调。|
2751
2752**示例:**
2753  ```ts
2754  import { AsyncCallback, BusinessError } from '@ohos.base';
2755  let plugin: account_osAccount.DomainPlugin = {
2756    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2757          callback: account_osAccount.IUserAuthCallback) => {},
2758    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2759                    callback: account_osAccount.IUserAuthCallback) => {},
2760    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2761                    callback: account_osAccount.IUserAuthCallback) => {},
2762    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2763                    callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
2764    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2765                        callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
2766    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2767                  callback: AsyncCallback<void>) => {},
2768    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
2769    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2770                          callback: AsyncCallback<boolean>) => {},
2771    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {
2772      // mock getting operation
2773      // notify result
2774      let code: BusinessError = {
2775        code: 0,
2776        name: "",
2777        message: ""
2778      };
2779      let token: Uint8Array = new Uint8Array([0]);
2780      callback(code, token);
2781    }
2782  }
2783  account_osAccount.DomainAccountManager.registerPlugin(plugin)
2784  ```
2785
2786## DomainAccountManager <sup>9+</sup>
2787域帐号管理器类。
2788
2789### registerPlugin<sup>9+</sup>
2790
2791static registerPlugin(plugin: DomainPlugin): void
2792
2793注册域插件。
2794
2795**系统接口:** 此接口为系统接口。
2796
2797**系统能力:** SystemCapability.Account.OsAccount
2798
2799**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
2800
2801**参数:**
2802
2803| 参数名    | 类型                     | 必填 | 说明                      |
2804| ----------| ----------------------- | --- | -------------------------- |
2805| plugin   | [DomainPlugin](#domainplugin9)  | 是  | 指示域插件。 |
2806
2807**错误码:**
2808
2809| 错误码ID | 错误信息                     |
2810| -------- | --------------------------- |
2811| 12300201 | The domain plugin has been registered. |
2812
2813**示例:**
2814  ```ts
2815  import { AsyncCallback } from '@ohos.base';
2816  let plugin: account_osAccount.DomainPlugin = {
2817    auth: (domainAccountInfo: account_osAccount.DomainAccountInfo, credential: Uint8Array,
2818         callback: account_osAccount.IUserAuthCallback) => {},
2819    authWithPopup: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2820                  callback: account_osAccount.IUserAuthCallback) => {},
2821    authWithToken: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2822                  callback: account_osAccount.IUserAuthCallback) => {},
2823    getAccountInfo: (options: account_osAccount.GetDomainAccountInfoPluginOptions,
2824                   callback: AsyncCallback<account_osAccount.DomainAccountInfo>) => {},
2825    getAuthStatusInfo: (domainAccountInfo: account_osAccount.DomainAccountInfo,
2826                        callback: AsyncCallback<account_osAccount.AuthStatusInfo>) => {},
2827    bindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, localId: number,
2828                  callback: AsyncCallback<void>) => {},
2829    unbindAccount: (domainAccountInfo: account_osAccount.DomainAccountInfo, callback: AsyncCallback<void>) => {},
2830    isAccountTokenValid: (domainAccountInfo: account_osAccount.DomainAccountInfo, token: Uint8Array,
2831                        callback: AsyncCallback<boolean>) => {},
2832    getAccessToken: (options: account_osAccount.GetDomainAccessTokenOptions, callback: AsyncCallback<Uint8Array>) => {}
2833  }
2834  try {
2835    account_osAccount.DomainAccountManager.registerPlugin(plugin);
2836    console.log('registerPlugin success.');
2837  } catch(err) {
2838    console.log('registerPlugin err:' + JSON.stringify(err));
2839  }
2840  ```
2841
2842### unregisterPlugin<sup>9+</sup>
2843
2844static unregisterPlugin(): void
2845
2846注销域插件。
2847
2848**系统接口:** 此接口为系统接口。
2849
2850**系统能力:** SystemCapability.Account.OsAccount
2851
2852**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
2853
2854**示例:**
2855  ```ts
2856  try {
2857    account_osAccount.DomainAccountManager.unregisterPlugin();
2858    console.log('unregisterPlugin success.');
2859  } catch(err) {
2860    console.log('unregisterPlugin err:' + JSON.stringify(err));
2861  }
2862  ```
2863
2864### auth<sup>10+</sup>
2865
2866auth(domainAccountInfo: DomainAccountInfo, credential: Uint8Array, callback: IUserAuthCallback): void
2867
2868认证指定的域帐号。
2869
2870**系统接口:** 此接口为系统接口。
2871
2872**系统能力:** SystemCapability.Account.OsAccount
2873
2874**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2875
2876**参数:**
2877
2878| 参数名      | 类型                                    | 必填 | 说明             |
2879| ---------- | --------------------------------------- | ---- | --------------- |
2880| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
2881| credential   | Uint8Array  | 是   | 指示域帐号的凭据。|
2882| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
2883
2884**错误码:**
2885
2886| 错误码ID | 错误信息                     |
2887| -------- | --------------------------- |
2888| 12300001 | System service exception. |
2889| 12300002 | Invalid domainAccountInfo or credential. |
2890| 12300003 | Domain account does not exist. |
2891| 12300013 | Network exception. |
2892| 12300101 | Authentication failed. |
2893| 12300109 | Authentication is canceled. |
2894| 12300110 | Authentication is locked. |
2895| 12300111 | Authentication timeout. |
2896| 12300112 | Authentication service is busy. |
2897| 12300113 | Authentication service does not exist. |
2898| 12300114 | Authentication service exception. |
2899
2900**示例:**
2901  ```ts
2902  let domainAccountInfo: account_osAccount.DomainAccountInfo = {
2903    domain: 'CHINA',
2904    accountName: 'zhangsan'
2905  }
2906  let credential = new Uint8Array([0])
2907  try {
2908    account_osAccount.DomainAccountManager.auth(domainAccountInfo, credential, {
2909      onResult: (resultCode: number, authResult: account_osAccount.AuthResult) => {
2910        console.log('auth resultCode = ' + resultCode);
2911        console.log('auth authResult = ' + JSON.stringify(authResult));
2912      }
2913    });
2914  } catch (err) {
2915    console.log('auth exception = ' + JSON.stringify(err));
2916  }
2917  ```
2918
2919### authWithPopup<sup>10+</sup>
2920
2921authWithPopup(callback: IUserAuthCallback): void
2922
2923弹框认证指定的域帐号。
2924
2925**系统接口:** 此接口为系统接口。
2926
2927**系统能力:** SystemCapability.Account.OsAccount
2928
2929**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2930
2931从API version 11开始无需申请权限,建议升级SDK版本。
2932
2933**参数:**
2934
2935| 参数名      | 类型                                    | 必填 | 说明             |
2936| ---------- | --------------------------------------- | ---- | --------------- |
2937| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
2938
2939**错误码:**
2940
2941| 错误码ID | 错误信息                     |
2942| -------- | --------------------------- |
2943| 12300001 | System service exception. |
2944| 12300003 | No domain account is bound. |
2945| 12300013 | Network exception. |
2946| 12300101 | Authentication failed. |
2947| 12300109 | Authentication is canceled. |
2948| 12300110 | Authentication is locked. |
2949| 12300111 | Authentication timeout. |
2950| 12300112 | Authentication service is busy. |
2951| 12300113 | Authentication service does not exist. |
2952| 12300114 | Authentication service exception. |
2953
2954**示例:**
2955  ```ts
2956  try {
2957    account_osAccount.DomainAccountManager.authWithPopup({
2958      onResult: (resultCode: number, authResult: account_osAccount.AuthResult) => {
2959        console.log('auth resultCode = ' + resultCode);
2960        console.log('auth authResult = ' + JSON.stringify(authResult));
2961      }
2962    })
2963  } catch (err) {
2964    console.log('auth exception = ' + JSON.stringify(err));
2965  }
2966  ```
2967
2968### authWithPopup<sup>10+</sup>
2969
2970authWithPopup(localId: number, callback: IUserAuthCallback): void
2971
2972弹框认证指定的域帐号。
2973
2974**系统接口:** 此接口为系统接口。
2975
2976**系统能力:** SystemCapability.Account.OsAccount
2977
2978**需要权限:** ohos.permission.ACCESS_USER_AUTH_INTERNAL
2979
2980从API version 11开始无需申请权限,建议升级SDK版本。
2981
2982**参数:**
2983
2984| 参数名      | 类型                                    | 必填 | 说明             |
2985| ---------- | --------------------------------------- | ---- | --------------- |
2986| localId   | number  | 是   | 指示绑定域帐号的系统帐号的本地标识。|
2987| callback   | [IUserAuthCallback](#iuserauthcallback8)  | 是   | 指示认证结果回调。|
2988
2989**错误码:**
2990
2991| 错误码ID | 错误信息                     |
2992| -------- | --------------------------- |
2993| 12300001 | System service exception. |
2994| 12300002 | Invalid localId. |
2995| 12300003 | No domain account is bound. |
2996| 12300013 | Network exception. |
2997| 12300101 | Authentication failed. |
2998| 12300109 | Authentication is canceled. |
2999| 12300110 | Authentication is locked. |
3000| 12300111 | Authentication timeout. |
3001| 12300112 | Authentication service is busy. |
3002| 12300113 | Authentication service does not exist. |
3003| 12300114 | Authentication service exception. |
3004
3005**示例:**
3006  ```ts
3007  try {
3008    account_osAccount.DomainAccountManager.authWithPopup(100, {
3009      onResult: (resultCode: number, authResult: account_osAccount.AuthResult) => {
3010        console.log('authWithPopup resultCode = ' + resultCode);
3011        console.log('authWithPopup authResult = ' + JSON.stringify(authResult));
3012      }
3013    })
3014  } catch (err) {
3015    console.log('authWithPopup exception = ' + JSON.stringify(err));
3016  }
3017  ```
3018
3019### hasAccount<sup>10+</sup>
3020
3021hasAccount(domainAccountInfo: DomainAccountInfo, callback: AsyncCallback&lt;boolean&gt;): void
3022
3023检查是否存在指定的域帐号。
3024
3025**系统接口:** 此接口为系统接口。
3026
3027**系统能力:** SystemCapability.Account.OsAccount
3028
3029**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3030
3031**参数:**
3032
3033| 参数名      | 类型                                    | 必填 | 说明             |
3034| ---------- | --------------------------------------- | ---- | --------------- |
3035| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
3036| callback   | AsyncCallback&lt;boolean&gt;  | 是   | 指示检查结果回调。|
3037
3038**错误码:**
3039
3040| 错误码ID | 错误信息                     |
3041| -------- | --------------------------- |
3042| 12300001 | System service exception. |
3043| 12300002 | Invalid domainAccountInfo. |
3044| 12300013 | Network exception. |
3045| 12300111 | Operation timeout. |
3046
3047**示例:**
3048  ```ts
3049  import { BusinessError } from '@ohos.base';
3050  let domainAccountInfo: account_osAccount.DomainAccountInfo = {
3051    domain: 'CHINA',
3052    accountName: 'zhangsan'
3053  }
3054  try {
3055    account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo, (err: BusinessError, result: boolean) => {
3056      if (err) {
3057        console.log('call hasAccount failed, error: ' + JSON.stringify(err));
3058      } else {
3059        console.log('hasAccount result: ' + result);
3060      }
3061    });
3062  } catch (err) {
3063    console.log('hasAccount exception = ' + JSON.stringify(err));
3064  }
3065  ```
3066
3067### hasAccount<sup>10+</sup>
3068
3069hasAccount(domainAccountInfo: DomainAccountInfo): Promise&lt;boolean&gt;
3070
3071检查是否存在指定的域帐号。
3072
3073**系统接口:** 此接口为系统接口。
3074
3075**系统能力:** SystemCapability.Account.OsAccount
3076
3077**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3078
3079**参数:**
3080
3081| 参数名      | 类型                                    | 必填 | 说明             |
3082| ---------- | --------------------------------------- | ---- | --------------- |
3083| domainAccountInfo   | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
3084
3085**返回值:**
3086
3087| 类型                      | 说明                     |
3088| :------------------------ | ----------------------- |
3089| Promise&lt;boolean&gt; | Promise对象,返回指定的域帐号是否存在。 |
3090
3091**错误码:**
3092
3093| 错误码ID | 错误信息                     |
3094| -------- | --------------------------- |
3095| 12300001 | System service exception. |
3096| 12300002 | Invalid domainAccountInfo. |
3097| 12300013 | Network exception. |
3098| 12300111 | Operation timeout. |
3099
3100**示例:**
3101  ```ts
3102  import { BusinessError } from '@ohos.base';
3103  let domainAccountInfo: account_osAccount.DomainAccountInfo = {
3104    domain: 'CHINA',
3105    accountName: 'zhangsan'
3106  }
3107  try {
3108    account_osAccount.DomainAccountManager.hasAccount(domainAccountInfo).then((result: boolean) => {
3109      console.log('hasAccount result: ' + result);
3110    }).catch((err: BusinessError) => {
3111        console.log('call hasAccount failed, error: ' + JSON.stringify(err));
3112    });
3113  } catch (err) {
3114    console.log('hasAccount exception = ' + JSON.stringify(err));
3115  }
3116  ```
3117
3118### updateAccountToken<sup>10+</sup>
3119
3120updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array, callback: AsyncCallback&lt;void&gt;): void;
3121
3122更新指定域帐号的令牌,空令牌表示目标域帐号的令牌失效。使用callback异步回调。
3123
3124**系统接口:** 此接口为系统接口。
3125
3126**系统能力:** SystemCapability.Account.OsAccount
3127
3128**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3129
3130**参数:**
3131
3132| 参数名      | 类型                                    | 必填 | 说明             |
3133| ---------- | --------------------------------------- | ---- | --------------- |
3134| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
3135| token | Uint8Array  | 是   | 指示域帐号的令牌。|
3136| callback | AsyncCallback&lt;void&gt; | 是 | 回调函数。如果更新成功,err为null,否则为错误对象。|
3137
3138**错误码:**
3139
3140| 错误码ID | 错误信息                     |
3141| -------- | --------------------------- |
3142| 12300001 | System service exception. |
3143| 12300002 | Invalid token. |
3144| 12300003 | Account not found. |
3145
3146**示例:**
3147  ```ts
3148  import { BusinessError } from '@ohos.base';
3149  let domainAccountInfo: account_osAccount.DomainAccountInfo = {
3150    domain: 'CHINA',
3151    accountName: 'zhangsan',
3152    accountId: '123456'
3153  }
3154  let token = new Uint8Array([0])
3155  try {
3156    account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token, (err: BusinessError) => {
3157      if (err != null) {
3158        console.log('updateAccountToken failed, error: ' + JSON.stringify(err));
3159      } else {
3160        console.log('updateAccountToken successfully');
3161      }
3162    })
3163  } catch (err) {
3164    console.log('updateAccountToken exception = ' + JSON.stringify(err));
3165  }
3166  ```
3167
3168### updateAccountToken<sup>10+</sup>
3169
3170updateAccountToken(domainAccountInfo: DomainAccountInfo, token: Uint8Array): Promise&lt;void&gt;
3171
3172更新指定域帐号的令牌,空令牌表示目标域帐号的令牌失效。使用Promise异步回调。
3173
3174**系统接口:** 此接口为系统接口。
3175
3176**系统能力:** SystemCapability.Account.OsAccount
3177
3178**需要权限:** ohos.permission.MANAGE_LOCAL_ACCOUNTS
3179
3180**参数:**
3181
3182| 参数名      | 类型                                    | 必填 | 说明             |
3183| ---------- | --------------------------------------- | ---- | --------------- |
3184| domainAccountInfo | [DomainAccountInfo](#domainaccountinfo8)  | 是   | 指示域帐号信息。|
3185| token | Uint8Array  | 是   | 指示域帐号的令牌。|
3186
3187**返回值:**
3188
3189| 类型                      | 说明                     |
3190| :------------------------ | ----------------------- |
3191| Promise&lt;void&gt; | Promise对象,无返回结果的Promise对象。 |
3192
3193**错误码:**
3194
3195| 错误码ID | 错误信息                     |
3196| -------- | --------------------------- |
3197| 12300001 | System service exception. |
3198| 12300002 | Invalid token. |
3199| 12300003 | Account not found. |
3200
3201**示例:**
3202  ```ts
3203  import { BusinessError } from '@ohos.base';
3204  let domainAccountInfo: account_osAccount.DomainAccountInfo = {
3205    domain: 'CHINA',
3206    accountName: 'zhangsan',
3207    accountId: '123456'
3208  }
3209  let token = new Uint8Array([0])
3210  try {
3211    account_osAccount.DomainAccountManager.updateAccountToken(domainAccountInfo, token).then(() => {
3212      console.log('updateAccountToken successfully');
3213    }).catch((err: BusinessError) => {
3214        console.log('updateAccountToken failed, error: ' + JSON.stringify(err));
3215    });
3216  } catch (err) {
3217    console.log('updateAccountToken exception = ' + JSON.stringify(err));
3218  }
3219  ```
3220
3221### getAccountInfo<sup>10+</sup>
3222
3223getAccountInfo(options: GetDomainAccountInfoOptions, callback: AsyncCallback&lt;DomainAccountInfo&gt;): void
3224
3225查询指定的域帐号信息,callback方式。
3226
3227**系统接口:** 此接口为系统接口。
3228
3229**系统能力:** SystemCapability.Account.OsAccount
3230
3231**需要权限:** ohos.permission.GET_DOMAIN_ACCOUNTS
3232
3233**参数:**
3234
3235| 参数名      | 类型                                    | 必填 | 说明             |
3236| ---------- | --------------------------------------- | ---- | --------------- |
3237| options   | [GetDomainAccountInfoOptions](#getdomainaccountinfooptions10)  | 是   | 指示域帐号信息。|
3238| callback   | AsyncCallback&lt;DomainAccountInfo&gt;  | 是   | 指示查询结果回调。|
3239
3240**错误码:**
3241
3242| 错误码ID | 错误信息                     |
3243| -------- | --------------------------- |
3244| 12300001 | System service exception. |
3245| 12300003 | Account not found. |
3246| 12300013 | Network exception. |
3247| 12300111 | Operation timeout. |
3248
3249**示例:**
3250  ```ts
3251  import { BusinessError } from '@ohos.base';
3252  let domainAccountInfo: account_osAccount.GetDomainAccountInfoOptions = {
3253    domain: 'CHINA',
3254    accountName: 'zhangsan'
3255  }
3256  try {
3257    account_osAccount.DomainAccountManager.getAccountInfo(domainAccountInfo,
3258      (err: BusinessError, result: account_osAccount.DomainAccountInfo) => {
3259      if (err) {
3260        console.log('call getAccountInfo failed, error: ' + JSON.stringify(err));
3261      } else {
3262        console.log('getAccountInfo result: ' + result);
3263      }
3264    });
3265  } catch (err) {
3266    console.log('getAccountInfo exception = ' + JSON.stringify(err));
3267  }
3268  ```
3269
3270### getAccountInfo<sup>10+</sup>
3271
3272getAccountInfo(options: GetDomainAccountInfoOptions): Promise&lt;DomainAccountInfo&gt;
3273
3274查询指定的域帐号信息,promise方式。
3275
3276**系统接口:** 此接口为系统接口。
3277
3278**系统能力:** SystemCapability.Account.OsAccount
3279
3280**需要权限:** ohos.permission.GET_DOMAIN_ACCOUNTS
3281
3282**参数:**
3283
3284| 参数名      | 类型                                    | 必填 | 说明             |
3285| ---------- | --------------------------------------- | ---- | --------------- |
3286| options   | [GetDomainAccountInfoOptions](#getdomainaccountinfooptions10)  | 是   | 指示域帐号信息。|
3287
3288**返回值:**
3289
3290| 类型                      | 说明                     |
3291| :------------------------ | ----------------------- |
3292| Promise&lt;DomainAccountInfo&gt; | Promise对象,返回指定的域帐号信息。 |
3293
3294**错误码:**
3295
3296| 错误码ID | 错误信息                     |
3297| -------- | --------------------------- |
3298| 12300001 | System service exception. |
3299| 12300003 | Account not found. |
3300| 12300013 | Network exception. |
3301| 12300111 | Operation timeout. |
3302
3303**示例:**
3304  ```ts
3305  import { BusinessError } from '@ohos.base';
3306  let domainAccountInfo: account_osAccount.GetDomainAccountInfoOptions = {
3307    domain: 'CHINA',
3308    accountName: 'zhangsan'
3309  }
3310  try {
3311    account_osAccount.DomainAccountManager.getAccountInfo(domainAccountInfo)
3312      .then((result: account_osAccount.DomainAccountInfo) => {
3313      console.log('getAccountInfo result: ' + result);
3314    }).catch((err: BusinessError) => {
3315      console.log('call getAccountInfo failed, error: ' + JSON.stringify(err));
3316    });
3317  } catch (err) {
3318    console.log('getAccountInfo exception = ' + JSON.stringify(err));
3319  }
3320  ```
3321
3322### getAccessToken<sup>11+</sup>
3323
3324getAccessToken(businessParams: Record<string, Object>, callback: AsyncCallback&lt;Uint8Array&gt;): void
3325
3326获取当前域帐号的业务访问令牌,使用callback异步回调。
3327
3328**系统接口:** 此接口为系统接口。
3329
3330**系统能力:** SystemCapability.Account.OsAccount
3331
3332**参数:**
3333
3334| 参数名      | 类型                                    | 必填 | 说明             |
3335| ---------- | --------------------------------------- | ---- | --------------- |
3336| businessParams | Record<string, Object>  | 是   | 指示业务参数,具体格式取决于域插件的实现要求。|
3337| callback | AsyncCallback&lt;Uint8Array&gt;  | 是   | 指示结果回调。如果获取成功,err返回null,否则为错误对象。|
3338
3339**错误码:**
3340
3341| 错误码ID | 错误信息                     |
3342| -------- | --------------------------- |
3343| 12300001 | System service exception. |
3344| 12300002 | Invalid business parameters. |
3345| 12300003 | Domain account not found. |
3346| 12300013 | Network exception. |
3347| 12300014 | Domain account not authenticated. |
3348| 12300111 | Operation timeout. |
3349
3350**示例:**
3351  ```ts
3352  import { BusinessError } from '@ohos.base';
3353  let businessParams: Record<string, Object> = {
3354    'clientId': 'xxx',
3355    'secretId': 'yyy'
3356  };  // depends on the implementation of the domain plugin
3357  try {
3358    account_osAccount.DomainAccountManager.getAccessToken(businessParams,
3359      (err: BusinessError, result: Uint8Array) => {
3360      if (err) {
3361        console.log('getAccessToken failed, error: ' + JSON.stringify(err));
3362      } else {
3363        console.log('getAccessToken result: ' + result);
3364      }
3365    });
3366  } catch (err) {
3367    console.log('getAccessToken exception = ' + JSON.stringify(err));
3368  }
3369  ```
3370
3371### getAccessToken<sup>11+</sup>
3372
3373getAccessToken(businessParams: Record<string, Object>): Promise&lt;Uint8Array&gt;
3374
3375查询当前域帐号的业务访问令牌,使用promise异步回调。
3376
3377**系统接口:** 此接口为系统接口。
3378
3379**系统能力:** SystemCapability.Account.OsAccount
3380
3381**参数:**
3382
3383| 参数名      | 类型                                    | 必填 | 说明             |
3384| ---------- | --------------------------------------- | ---- | --------------- |
3385| businessParams | Record<string, Object> | 是   | 指示业务参数,具体格式取决于域插件的实现要求。|
3386
3387**返回值:**
3388
3389| 类型                      | 说明                     |
3390| :------------------------ | ----------------------- |
3391| Promise&lt;Uint8Array&gt; | Promise对象,返回业务访问令牌。 |
3392
3393**错误码:**
3394
3395| 错误码ID | 错误信息                     |
3396| -------- | --------------------------- |
3397| 12300001 | System service exception. |
3398| 12300002 | Invalid business parameters. |
3399| 12300003 | Domain account not found. |
3400| 12300013 | Network exception. |
3401| 12300014 | Domain account not authenticated. |
3402| 12300111 | Operation timeout. |
3403
3404**示例:**
3405  ```ts
3406  import { BusinessError } from '@ohos.base';
3407  let businessParams: Record<string, Object> = {
3408    'clientId': 'xxx',
3409    'secretId': 'yyy'
3410  };  // depends on the implementation of the domain plugin
3411  try {
3412    account_osAccount.DomainAccountManager.getAccessToken(businessParams)
3413      .then((result: Uint8Array) => {
3414      console.log('getAccessToken result: ' + result);
3415    }).catch((err: BusinessError) => {
3416      console.log('getAccessToken failed, error: ' + JSON.stringify(err));
3417    });
3418  } catch (err) {
3419    console.log('getAccessToken exception = ' + JSON.stringify(err));
3420  }
3421  ```
3422
3423## UserIdentityManager<sup>8+</sup>
3424
3425获取用户身份管理类。
3426
3427**系统接口:** 此接口为系统接口。
3428
3429### constructor<sup>8+</sup>
3430
3431constructor()
3432
3433用户身份管理类的默认构造函数。
3434
3435**系统接口:** 此接口为系统接口。
3436
3437**系统能力**:SystemCapability.Account.OsAccount
3438
3439**示例:**
3440  ```ts
3441  let userIDM = new account_osAccount.UserIdentityManager();
3442  ```
3443
3444### openSession<sup>8+</sup>
3445
3446openSession(callback: AsyncCallback&lt;Uint8Array&gt;): void;
3447
3448打开会话,获取挑战值。使用callback异步回调。
3449
3450**系统接口:** 此接口为系统接口。
3451
3452**系统能力:** SystemCapability.Account.OsAccount
3453
3454**需要权限:** ohos.permission.MANAGE_USER_IDM
3455
3456**参数:**
3457
3458| 参数名    | 类型                             | 必填 | 说明                                                            |
3459| -------- | -------------------------------- | ---- | -------------------------------------------------------------- |
3460| callback | AsyncCallback&lt;Uint8Array&gt;  | 是   | 回调函数。如果打开会话成功,err为null,data为挑战值;否则为错误对象。|
3461
3462**错误码:**
3463
3464| 错误码ID | 错误信息                     |
3465| -------- | --------------------------- |
3466| 12300001 | System service exception. |
3467
3468**示例:**
3469  ```ts
3470  import { BusinessError } from '@ohos.base';
3471  let userIDM = new account_osAccount.UserIdentityManager();
3472  try {
3473    userIDM.openSession((err: BusinessError, challenge: Uint8Array) => {
3474        console.log('openSession error = ' + JSON.stringify(err));
3475        console.log('openSession challenge = ' + JSON.stringify(challenge));
3476    });
3477  } catch (e) {
3478    console.log('openSession exception = ' + JSON.stringify(e));
3479  }
3480  ```
3481
3482### openSession<sup>8+</sup>
3483
3484openSession(): Promise&lt;Uint8Array&gt;;
3485
3486打开会话,获取挑战值。使用Promise异步回调。
3487
3488**系统接口:** 此接口为系统接口。
3489
3490**系统能力:** SystemCapability.Account.OsAccount
3491
3492**需要权限:** ohos.permission.MANAGE_USER_IDM
3493
3494**返回值:**
3495
3496| 类型                      | 说明                     |
3497| :------------------------ | ----------------------- |
3498| Promise&lt;Uint8Array&gt; | Promise对象,返回挑战值。 |
3499
3500**错误码:**
3501
3502| 错误码ID | 错误信息                     |
3503| -------- | --------------------------- |
3504| 12300001 | System service exception. |
3505
3506**示例:**
3507  ```ts
3508  import { BusinessError } from '@ohos.base';
3509  let userIDM = new account_osAccount.UserIdentityManager();
3510  try {
3511    userIDM.openSession().then((challenge: Uint8Array) => {
3512        console.info('openSession challenge = ' + JSON.stringify(challenge));
3513    }).catch((err: BusinessError) => {
3514        console.info('openSession error = ' + JSON.stringify(err));
3515    });
3516  } catch (e) {
3517    console.log('openSession exception = ' + JSON.stringify(e));
3518  }
3519  ```
3520
3521### addCredential<sup>8+</sup>
3522
3523addCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
3524
3525添加凭据,添加用户凭据信息,传入凭据添加方法和凭据信息(凭据类型,子类,如果添加用户的非密码凭据,则传入密码身份验证令牌),并获取结果/获取信息。
3526
3527**系统接口:** 此接口为系统接口。
3528
3529**系统能力:** SystemCapability.Account.OsAccount
3530
3531**需要权限:** ohos.permission.MANAGE_USER_IDM
3532
3533**参数:**
3534
3535| 参数名           | 类型                                 | 必填 | 说明                        |
3536| --------------- | ------------------------------------ | --- | ---------------------------- |
3537| credentialInfo  | [CredentialInfo](#credentialinfo8)   | 是  | 指示凭据信息。                |
3538| callback        | [IIdmCallback](#iidmcallback8)       | 是  | 回调对象,返回添加凭据的结果。  |
3539
3540**错误码:**
3541
3542| 错误码ID | 错误信息                     |
3543| -------- | ------------------- |
3544| 12300001 | System service exception. |
3545| 12300002 | Invalid credentialInfo, i.e. authType or authSubType. |
3546| 12300101 | Token is invalid. |
3547| 12300106 | Unsupported authType. |
3548| 12300109 | Operation is canceled. |
3549| 12300111 | Operation timeout. |
3550| 12300115 | The number of credentials reaches the upper limit. |
3551
3552**示例:**
3553  ```ts
3554  import { BusinessError } from '@ohos.base';
3555  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
3556  let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
3557  pinAuth.registerInputer({
3558    onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
3559      callback.onSetData(authSubType, password);
3560    }
3561  });
3562  let credentialInfo: account_osAccount.CredentialInfo = {
3563    credType: account_osAccount.AuthType.PIN,
3564    credSubType: account_osAccount.AuthSubType.PIN_SIX,
3565    token: new Uint8Array([]),
3566  };
3567  let userIDM = new account_osAccount.UserIdentityManager();
3568  userIDM.openSession((err: BusinessError, challenge: Uint8Array) => {
3569    try {
3570    userIDM.addCredential(credentialInfo, {
3571      onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
3572        console.log('addCredential result = ' + result);
3573        console.log('addCredential extraInfo = ' + extraInfo);
3574      }
3575    });
3576    } catch (e) {
3577      console.log('addCredential exception = ' + JSON.stringify(e));
3578    }
3579  });
3580  ```
3581
3582### updateCredential<sup>8+</sup>
3583
3584updateCredential(credentialInfo: CredentialInfo, callback: IIdmCallback): void;
3585
3586更新凭据。使用callback异步回调。
3587
3588**系统接口:** 此接口为系统接口。
3589
3590**系统能力:** SystemCapability.Account.OsAccount
3591
3592**需要权限:** ohos.permission.MANAGE_USER_IDM
3593
3594**参数:**
3595
3596| 参数名           | 类型                                  | 必填 | 说明                     |
3597| --------------- | ------------------------------------- | --- | ------------------------- |
3598| credentialInfo  | [CredentialInfo](#credentialinfo8)    | 是  | 指示凭据信息。             |
3599| callback        | [IIdmCallback](#iidmcallback8)        | 是  | 回调对象,返回更新凭据的结果。 |
3600
3601**错误码:**
3602
3603| 错误码ID | 错误信息                     |
3604| -------- | ------------------- |
3605| 12300001 | System service exception. |
3606| 12300002 | Invalid credentialInfo, i.e. authType or authSubType or token. |
3607| 12300101 | Token is invalid. |
3608| 12300102 | Credential not enrolled.|
3609| 12300106 | Unsupported authType. |
3610| 12300109 | Operation is canceled. |
3611| 12300111 | Operation timeout. |
3612
3613**示例:**
3614  ```ts
3615  import { BusinessError } from '@ohos.base';
3616  let userIDM = new account_osAccount.UserIdentityManager();
3617  let userAuth: account_osAccount.UserAuth = new account_osAccount.UserAuth();
3618  let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
3619  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
3620  let credentialInfo: account_osAccount.CredentialInfo = {
3621    credType: account_osAccount.AuthType.PIN,
3622    credSubType: account_osAccount.AuthSubType.PIN_SIX,
3623    token: new Uint8Array([]),
3624  };
3625  pinAuth.registerInputer({
3626    onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
3627      callback.onSetData(authSubType, password);
3628    }
3629  });
3630  userIDM.openSession((err: BusinessError, challenge: Uint8Array) => {
3631    userAuth.auth(challenge, credentialInfo.credType, account_osAccount.AuthTrustLevel.ATL1, {
3632      onResult: (result: number, extraInfo: account_osAccount.AuthResult) => {
3633        if (result != account_osAccount.ResultCode.SUCCESS) {
3634          return;
3635        }
3636        if (extraInfo.token != null) {
3637          credentialInfo.token = extraInfo.token;
3638        }
3639        try {
3640          userIDM.updateCredential(credentialInfo, {
3641            onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
3642                console.log('updateCredential result = ' + result);
3643                console.log('updateCredential extraInfo = ' + extraInfo);
3644            }
3645          });
3646        } catch (e) {
3647          console.log('updateCredential exception = ' + JSON.stringify(e));
3648        }
3649      }
3650    });
3651  });
3652  ```
3653
3654### closeSession<sup>8+</sup>
3655
3656closeSession(): void;
3657
3658关闭会话,结束IDM操作。
3659
3660**系统接口:** 此接口为系统接口。
3661
3662**系统能力:** SystemCapability.Account.OsAccount
3663
3664**需要权限:** ohos.permission.MANAGE_USER_IDM
3665
3666**示例:**
3667  ```ts
3668  let userIDM = new account_osAccount.UserIdentityManager();
3669  userIDM.closeSession();
3670  ```
3671
3672### cancel<sup>8+</sup>
3673
3674cancel(challenge: Uint8Array): void;
3675
3676根据挑战值取消条目。
3677
3678**系统接口:** 此接口为系统接口。
3679
3680**系统能力:** SystemCapability.Account.OsAccount
3681
3682**需要权限:** ohos.permission.MANAGE_USER_IDM
3683
3684**参数:**
3685
3686| 参数名    | 类型        | 必填 | 说明   |
3687| -------- | ----------- | ---- | ----- |
3688| challenge | Uint8Array | 是   | 挑战值。 |
3689
3690**错误码:**
3691
3692| 错误码ID | 错误信息            |
3693| -------- | ------------------- |
3694| 12300001 | System service exception. |
3695| 12300002 | Invalid challenge. |
3696
3697**示例:**
3698  ```ts
3699  let userIDM = new account_osAccount.UserIdentityManager();
3700  let challenge: Uint8Array = new Uint8Array([0]);
3701  try {
3702    userIDM.cancel(challenge);
3703  } catch(err) {
3704    console.log('cancel err:' + JSON.stringify(err));
3705  }
3706  ```
3707
3708### delUser<sup>8+</sup>
3709
3710delUser(token: Uint8Array, callback: IIdmCallback): void;
3711
3712删除具有身份验证令牌的用户,使用callback方式异步返回结果。
3713
3714**系统接口:** 此接口为系统接口。
3715
3716**系统能力:** SystemCapability.Account.OsAccount
3717
3718**需要权限:** ohos.permission.MANAGE_USER_IDM
3719
3720**参数:**
3721
3722| 参数名    | 类型                           | 必填 | 说明                      |
3723| -------- | ------------------------------ | --- | ------------------------- |
3724| token    | Uint8Array                     | 是  | 身份验证令牌。             |
3725| callback | [IIdmCallback](#iidmcallback8) | 是  | 回调对象,返回删除用户的结果。|
3726
3727**错误码:**
3728
3729| 错误码ID | 错误信息        |
3730| -------- | ------------------- |
3731| 12300001 | System service exception. |
3732| 12300101 | Token is invalid. |
3733
3734**示例:**
3735  ```ts
3736  let userIDM = new account_osAccount.UserIdentityManager();
3737  let token: Uint8Array = new Uint8Array([0]);
3738  try {
3739    userIDM.delUser(token, {
3740      onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
3741        console.log('delUser result = ' + result);
3742        console.log('delUser extraInfo = ' + JSON.stringify(extraInfo));
3743      }
3744    });
3745  } catch (e) {
3746    console.log('delUser exception = ' + JSON.stringify(e));
3747  }
3748  ```
3749
3750### delCred<sup>8+</sup>
3751
3752delCred(credentialId: Uint8Array, token: Uint8Array, callback: IIdmCallback): void;
3753
3754删除用户凭据信息。
3755
3756**系统接口:** 此接口为系统接口。
3757
3758**系统能力:** SystemCapability.Account.OsAccount
3759
3760**需要权限:** ohos.permission.MANAGE_USER_IDM
3761
3762**参数:**
3763
3764| 参数名           | 类型                                            | 必填 | 说明                      |
3765| --------------- | ----------------------------------- | --- | ---------------------------|
3766| credentialId    | Uint8Array                          | 是  | 凭证索引。                  |
3767| token           | Uint8Array                          | 是  | 身份验证令牌。               |
3768| callback        | [IIdmCallback](#iidmcallback8)      | 是  | 回调对象,返回删除凭据的结果。 |
3769
3770**错误码:**
3771
3772| 错误码ID | 错误信息             |
3773| -------- | ------------------- |
3774| 12300001 | System service exception. |
3775| 12300002 | Invalid credentialId. |
3776| 12300101 | Token is invalid. |
3777| 12300102 | Credential not enrolled. |
3778
3779**示例:**
3780  ```ts
3781  let userIDM = new account_osAccount.UserIdentityManager();
3782  let credentialId: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]);
3783  let token: Uint8Array = new Uint8Array([0]);
3784  try {
3785    userIDM.delCred(credentialId, token, {
3786      onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
3787          console.log('delCred result = ' + result);
3788          console.log('delCred extraInfo = ' + JSON.stringify(extraInfo));
3789      }
3790    });
3791  } catch (e) {
3792    console.log('delCred exception = ' + JSON.stringify(e));
3793  }
3794  ```
3795
3796### getAuthInfo<sup>8+</sup>
3797
3798getAuthInfo(callback: AsyncCallback&lt;Array&lt;EnrolledCredInfo&gt;&gt;): void;
3799
3800获取认证信息。使用callback异步回调。
3801
3802**系统接口:** 此接口为系统接口。
3803
3804**系统能力:** SystemCapability.Account.OsAccount
3805
3806**需要权限:** ohos.permission.USE_USER_IDM
3807
3808**参数:**
3809
3810| 参数名    | 类型                                                                     | 必填 | 说明                                                 |
3811| -------- | ------------------------------------------------------------------------ | ---- | --------------------------------------------- |
3812| callback | AsyncCallback&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | 是   | 回调函数。如果成功,err为null,data为当前用户的所有已注册凭据信息;否则为错误对象。|
3813
3814**错误码:**
3815
3816| 错误码ID | 错误信息               |
3817| -------- | --------------------- |
3818| 12300001 | System service exception. |
3819| 12300102 | Credential not enrolled. |
3820
3821**示例:**
3822  ```ts
3823  import { BusinessError } from '@ohos.base';
3824  let userIDM = new account_osAccount.UserIdentityManager();
3825  try {
3826    userIDM.getAuthInfo((err: BusinessError, result: account_osAccount.EnrolledCredInfo[]) => {
3827      console.log('getAuthInfo err = ' + JSON.stringify(err));
3828      console.log('getAuthInfo result = ' + JSON.stringify(result));
3829    });
3830  } catch (e) {
3831    console.log('getAuthInfo exception = ' + JSON.stringify(e));
3832  }
3833  ```
3834
3835### getAuthInfo<sup>8+</sup>
3836
3837getAuthInfo(authType: AuthType, callback: AsyncCallback&lt;Array&lt;EnrolledCredInfo&gt;&gt;): void;
3838
3839获取指定类型的认证信息。使用callback异步回调。
3840
3841**系统接口:** 此接口为系统接口。
3842
3843**系统能力:** SystemCapability.Account.OsAccount
3844
3845**需要权限:** ohos.permission.USE_USER_IDM
3846
3847**参数:**
3848
3849| 参数名    | 类型                                               | 必填 | 说明                                                |
3850| -------- | -------------------------------------------------- | ---- | -------------------------------------------------- |
3851| authType | [AuthType](#authtype8) | 是   | 认证类型。                                          |
3852| callback | AsyncCallback&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | 是   | 回调函数,如果获取成功,err为null,data为当前用户指定类型的所有已注册凭据信息;否则为错误对象。 |
3853
3854**错误码:**
3855
3856| 错误码ID | 错误信息               |
3857| -------- | ------------------- |
3858| 12300001 | System service exception. |
3859| 12300002 | Invalid authType. |
3860| 12300102 | Credential not enrolled. |
3861
3862**示例:**
3863  ```ts
3864  import { BusinessError } from '@ohos.base';
3865  let userIDM = new account_osAccount.UserIdentityManager();
3866  try {
3867    userIDM.getAuthInfo(account_osAccount.AuthType.PIN,
3868      (err: BusinessError, result: account_osAccount.EnrolledCredInfo[]) => {
3869      console.log('getAuthInfo err = ' + JSON.stringify(err));
3870      console.log('getAuthInfo result = ' + JSON.stringify(result));
3871    });
3872  } catch (e) {
3873    console.log('getAuthInfo exception = ' + JSON.stringify(e));
3874  }
3875  ```
3876
3877### getAuthInfo<sup>8+</sup>
3878
3879getAuthInfo(authType?: AuthType): Promise&lt;Array&lt;EnrolledCredInfo&gt;&gt;;
3880
3881获取认证信息。使用Promise异步回调。
3882
3883**系统接口:** 此接口为系统接口。
3884
3885**系统能力:** SystemCapability.Account.OsAccount
3886
3887**需要权限:** ohos.permission.USE_USER_IDM
3888
3889**参数:**
3890
3891| 参数名    | 类型                                | 必填 | 说明      |
3892| -------- | ----------------------------------- | ---- | -------- |
3893| authType | [AuthType](#authtype8)              | 否   | 认证类型,默认为空,表示查询所有认证类型的信息。|
3894
3895**返回值:**
3896
3897| 类型                                         | 说明                                                                     |
3898| :------------------------------------------- | :----------------------------------------------------------------------- |
3899| Promise&lt;Array&lt;[EnrolledCredInfo](#enrolledcredinfo8)&gt;&gt; | Promise对象,返回当前用户指定类型的所有已注册凭据信息。|
3900
3901**错误码:**
3902
3903| 错误码ID | 错误信息               |
3904| -------- | ------------------- |
3905| 12300001 | System service exception. |
3906| 12300002 | Invalid authType. |
3907| 12300102 | Credential not enrolled. |
3908
3909**示例:**
3910  ```ts
3911  import { BusinessError } from '@ohos.base';
3912  let userIDM = new account_osAccount.UserIdentityManager();
3913  try {
3914    userIDM.getAuthInfo(account_osAccount.AuthType.PIN).then((result: account_osAccount.EnrolledCredInfo[]) => {
3915      console.log('getAuthInfo result = ' + JSON.stringify(result))
3916    }).catch((err: BusinessError) => {
3917      console.log('getAuthInfo error = ' + JSON.stringify(err));
3918    });
3919  } catch (e) {
3920    console.log('getAuthInfo exception = ' + JSON.stringify(e));
3921  }
3922  ```
3923
3924## IInputData<sup>8+</sup>
3925
3926密码数据回调。
3927
3928**系统接口:** 此接口为系统接口。
3929
3930### onSetData<sup>8+</sup>
3931
3932onSetData: (authSubType: AuthSubType, data: Uint8Array) => void;
3933
3934**系统接口:** 此接口为系统接口。
3935
3936通知设置数据。
3937
3938**系统能力:** SystemCapability.Account.OsAccount
3939
3940**参数:**
3941
3942| 参数名      | 类型                                     | 必填 | 说明                                            |
3943| ---------- | ---------------------------------------- | ---- | ----------------------------------------------- |
3944| authSubType | [AuthSubType](#authsubtype8)             | 是   | 用于认证的凭据子类型。                            |
3945| data       | Uint8Array                               | 是   | 要设置的数据是凭据,用来在认证、添加、修改凭据操作。 |
3946
3947**错误码:**
3948
3949| 错误码ID | 错误信息               |
3950| -------- | ------------------- |
3951| 12300002 | Invalid pinSubType. |
3952
3953**示例:**
3954  ```ts
3955  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
3956  let passwordNumber: Uint8Array = new Uint8Array([1, 2, 3, 4]);
3957  let inputer: account_osAccount.IInputer = {
3958    onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
3959        if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
3960          callback.onSetData(authSubType, passwordNumber);
3961        } else {
3962          callback.onSetData(authSubType, password);
3963        }
3964    }
3965  };
3966  ```
3967
3968## IInputer<sup>8+</sup>
3969
3970凭据输入器回调。
3971
3972**系统接口:** 此接口为系统接口。
3973
3974### onGetData<sup>8+</sup>
3975
3976onGetData: (authSubType: AuthSubType, callback: IInputData) => void;
3977
3978通知获取数据。
3979
3980**系统接口:** 此接口为系统接口。
3981
3982**系统能力:** SystemCapability.Account.OsAccount
3983
3984**参数:**
3985
3986| 参数名      | 类型                                    | 必填 | 说明             |
3987| ---------- | --------------------------------------- | ---- | --------------- |
3988| callback   | [IInputData](#iinputdata8)  | 是   | 指示密码数据回调。|
3989
3990**示例:**
3991  ```ts
3992  let password: Uint8Array = new Uint8Array([0, 0, 0, 0, 0, 0]);
3993  let passwordNumber: Uint8Array = new Uint8Array([1, 2, 3, 4]);
3994  let inputer: account_osAccount.IInputer = {
3995    onGetData: (authSubType: account_osAccount.AuthSubType, callback: account_osAccount.IInputData) => {
3996        if (authSubType == account_osAccount.AuthSubType.PIN_NUMBER) {
3997          callback.onSetData(authSubType, passwordNumber);
3998        } else {
3999          callback.onSetData(authSubType, password);
4000        }
4001    }
4002  };
4003  let pinAuth: account_osAccount.PINAuth = new account_osAccount.PINAuth();
4004  let result = pinAuth.registerInputer(inputer);
4005  console.log('registerInputer result: ' + result);
4006  ```
4007
4008## IUserAuthCallback<sup>8+</sup>
4009
4010表示用户认证回调类。
4011
4012**系统接口:** 此接口为系统接口。
4013
4014### onResult<sup>8+</sup>
4015
4016onResult: (result: number, extraInfo: AuthResult) => void;
4017
4018身份认证结果回调函数,返回结果码和认证结果信息。
4019
4020**系统接口:** 此接口为系统接口。
4021
4022**系统能力:** SystemCapability.Account.OsAccount
4023
4024**参数:**
4025
4026| 参数名     | 类型                                    | 必填 | 说明                 |
4027| --------- | --------------------------------------- | ---- | ------------------- |
4028| result    | number                                   | 是   | 表示身份认证结果代码。|
4029| extraInfo | [AuthResult](#authresult8)  | 是   | 表示不同情况下的具体信息,如果认证通过,则在extrainfo中返回认证令牌,如果身份验证失败,则在extrainfo中返回剩余的身份验证时间,如果身份验证执行器被锁定,冻结时间将在extrainfo中返回。|
4030
4031**示例:**
4032  ```ts
4033  let authCallback: account_osAccount.IUserAuthCallback = {
4034    onResult: (result: number, extraInfo: account_osAccount.AuthResult) => {
4035      console.log('auth result = ' + result);
4036      console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
4037    }
4038  };
4039  ```
4040
4041### onAcquireInfo?<sup>8+</sup>
4042
4043onAcquireInfo?: (module: number, acquire: number, extraInfo: Uint8Array) => void;
4044
4045身份认证信息获取回调函数。
4046
4047**系统接口:** 此接口为系统接口。
4048
4049**系统能力:** SystemCapability.Account.OsAccount
4050
4051**参数:**
4052
4053| 参数名    | 类型     | 必填 | 说明                           |
4054| --------- | ------- | ---- | ----------------------------- |
4055| module    | number  | 是   | 指示用于身份验证的执行器类型。   |
4056| acquire   | number  | 是   | 指示不同身份验证执行器的tip代码。|
4057| extraInfo | Uint8Array     | 是   | 保留参数。                     |
4058
4059**示例:**
4060  ```ts
4061  let authCallback: account_osAccount.IUserAuthCallback = {
4062    onResult: (result: number, extraInfo: account_osAccount.AuthResult) => {
4063      console.log('auth result = ' + result)
4064      console.log('auth extraInfo = ' + JSON.stringify(extraInfo));
4065    },
4066    onAcquireInfo: (module: number, acquire: number, extraInfo: Uint8Array) => {
4067      console.log('auth module = ' + module);
4068      console.log('auth acquire = ' + acquire);
4069      console.info('auth extraInfo = ' + JSON.stringify(extraInfo));
4070    }
4071  };
4072  ```
4073
4074## IIdmCallback<sup>8+</sup>
4075
4076表示身份管理回调类。
4077
4078**系统接口:** 此接口为系统接口。
4079
4080### onResult<sup>8+</sup>
4081
4082onResult: (result: number, extraInfo: RequestResult) => void;
4083
4084身份管理操作结果回调函数,返回结果码和请求结果信息。
4085
4086**系统接口:** 此接口为系统接口。
4087
4088**系统能力:** SystemCapability.Account.OsAccount
4089
4090**参数:**
4091
4092| 参数名     | 类型                                    | 必填 | 说明                     |
4093| --------- | --------------------------------------- | ---- | ----------------------- |
4094| result    | number                                  | 是   | 表示身份认证结果代码。    |
4095| extraInfo | [RequestResult](#requestresult8)  | 是   | 针对不同情况传递具体信息。|
4096
4097**示例:**
4098  ```ts
4099  let idmCallback: account_osAccount.IIdmCallback = {
4100    onResult: (result: number, extraInfo: account_osAccount.RequestResult) => {
4101      console.log('callback result = ' + result)
4102      console.info('callback extraInfo = ' + JSON.stringify(extraInfo));
4103    }
4104  };
4105  ```
4106
4107### onAcquireInfo?<sup>8+</sup>
4108
4109onAcquireInfo?: (module: number, acquire: number, extraInfo: Uint8Array) => void;
4110
4111身份管理信息获取回调函数。
4112
4113**系统接口:** 此接口为系统接口。
4114
4115**系统能力:** SystemCapability.Account.OsAccount
4116
4117**参数:**
4118
4119| 参数名    | 类型     | 必填 | 说明                           |
4120| --------- | ------- | ---- | ----------------------------- |
4121| module    | number  | 是   | 指示用于身份验证的执行器类型。   |
4122| acquire   | number  | 是   | 指示不同身份验证执行器的tip代码。|
4123| extraInfo | Uint8Array | 是   | 保留参数。                     |
4124
4125**示例:**
4126  ```ts
4127  let idmCallback: account_osAccount.IIdmCallback = {
4128    onResult: (result: number, extraInfo: Object) => {
4129      console.log('callback result = ' + result)
4130      console.log('callback onResult = ' + JSON.stringify(extraInfo));
4131    },
4132    onAcquireInfo: (module: number, acquire: number, extraInfo: Uint8Array) => {
4133      console.log('callback module = ' + module);
4134      console.log('callback acquire = ' + acquire);
4135      console.log('callback onacquireinfo = ' + JSON.stringify(extraInfo));
4136    }
4137  };
4138  ```
4139
4140## GetPropertyRequest<sup>8+</sup>
4141
4142提供获取属性请求的信息。
4143
4144**系统接口:** 此接口为系统接口。
4145
4146**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4147
4148| 名称    | 类型                                                          | 必填   | 说明                   |
4149| -------- | ------------------------------------------------------------- | ----- | ----------------------- |
4150| authType | [AuthType](#authtype8)                            | 是    | 身份验证凭据类型。        |
4151| keys     | Array&lt;[GetPropertyType](#getpropertytype8)&gt; | 是    | 指示要获取的属性类型数组。 |
4152
4153## SetPropertyRequest<sup>8+</sup>
4154
4155提供设置属性请求的信息。
4156
4157**系统接口:** 此接口为系统接口。
4158
4159**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4160
4161| 名称    | 类型                                             | 必填   | 说明                 |
4162| -------- | ------------------------------------------------ | ----- | -------------------- |
4163| authType | [AuthType](#authtype8)               | 是    | 身份验证凭据类型。     |
4164| key     | [SetPropertyType](#setpropertytype8) | 是    | 指示要设置的属性类型。 |
4165| setInfo  | Uint8Array                                       | 是    | 指示要设置的信息。     |
4166
4167## ExecutorProperty<sup>8+</sup>
4168
4169提供执行器的属性。
4170
4171**系统接口:** 此接口为系统接口。
4172
4173**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4174
4175| 名称         | 类型                         |  可读 | 可写 | 说明              |
4176| ------------ | ---------------------------- | ----- | -----|----------------- |
4177| result       | number                       | 是    | 是   | 指示结果。         |
4178| authSubType  | [AuthSubType](#authsubtype8) | 是    | 是   | 指示认证凭据子类型。|
4179| remainTimes  | number                       | 是    | 是   | 指示剩余次数。     |
4180| freezingTime | number                       | 是    | 是   | 指示冻结时间。     |
4181| enrollmentProgress<sup>10+</sup> | string   | 是    | 是   | 指示录入进度,默认为空。 |
4182| sensorInfo<sup>10+</sup> | string           | 是    | 是   | 指示传感器信息,默认为空。 |
4183
4184## AuthResult<sup>8+</sup>
4185
4186表示认证结果的信息。
4187
4188**系统接口:** 此接口为系统接口。
4189
4190**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4191
4192| 名称        | 类型        | 必填   | 说明              |
4193| ------------ | ----------- | ----- | ----------------- |
4194| token        | Uint8Array  | 否    | 指示认证令牌,默认为空。      |
4195| remainTimes  | number      | 否    | 指示剩余次数,默认为空。      |
4196| freezingTime | number      | 否    | 指示冻结时间,默认为空。      |
4197
4198## CredentialInfo<sup>8+</sup>
4199
4200表示凭证信息。
4201
4202**系统接口:** 此接口为系统接口。
4203
4204**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4205
4206| 名称        | 类型                                     | 必填   | 说明              |
4207| ------------ | ---------------------------------------- | ----- | ----------------- |
4208| credType     | [AuthType](#authtype8)       | 是    | 指示凭据类型。     |
4209| credSubType  | [AuthSubType](#authsubtype8) | 是    | 指示凭据子类型。   |
4210| token        | Uint8Array                           | 是    | 指示认证令牌。     |
4211
4212## RequestResult<sup>8+</sup>
4213
4214表示请求结果的信息。
4215
4216**系统接口:** 此接口为系统接口。
4217
4218**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4219
4220| 名称        | 类型        | 必填   | 说明              |
4221| ------------ | ----------- | ----- | ----------------- |
4222| credentialId | Uint8Array  | 否    | 指示凭据索引,默认为空。      |
4223
4224## EnrolledCredInfo<sup>8+</sup>
4225
4226表示已注册凭据的信息。
4227
4228**系统接口:** 此接口为系统接口。
4229
4230**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4231
4232| 名称        | 类型                                     | 必填   | 说明              |
4233| ------------ | ---------------------------------------- | ----- | ------------------- |
4234| credentialId | Uint8Array                               | 是    | 指示凭据索引。       |
4235| authType     | [AuthType](#authtype8)       | 是    | 指示认证凭据类型。   |
4236| authSubType  | [AuthSubType](#authsubtype8) | 是    | 指示认证凭据子类型。 |
4237| templateId   | Uint8Array                               | 是    | 指示凭据模板ID。     |
4238
4239## GetPropertyType<sup>8+</sup>
4240
4241表示要获取的属性类型的枚举。
4242
4243**系统接口:** 此接口为系统接口。
4244
4245**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4246
4247| 名称           | 值 | 说明      |
4248| ------------- | ------ | --------- |
4249| AUTH_SUB_TYPE | 1      | 认证子类型。 |
4250| REMAIN_TIMES  | 2      | 剩余时间。   |
4251| FREEZING_TIME | 3      | 冻结时间。   |
4252| ENROLLMENT_PROGRESS<sup>10+</sup> | 4      | 录入进度。   |
4253| SENSOR_INFO<sup>10+</sup> | 5      | 传感器信息。   |
4254
4255## SetPropertyType<sup>8+</sup>
4256
4257表示要设置的属性类型的枚举。
4258
4259**系统接口:** 此接口为系统接口。
4260
4261**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4262
4263| 名称           | 值 | 说明        |
4264| -------------- | ----- | ----------- |
4265| INIT_ALGORITHM | 1     | 初始化算法。 |
4266
4267## AuthType<sup>8+</sup>
4268
4269表示身份验证的凭据类型的枚举。
4270
4271**系统接口:** 此接口为系统接口。
4272
4273**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4274
4275| 名称  | 值 | 说明             |
4276| ----- | ----- | ---------------- |
4277| PIN   | 1     | 表示PIN认证类型。 |
4278| FACE  | 2     | 表示脸部认证类型。|
4279| FINGERPRINT<sup>10+</sup>   | 4     | 表示指纹认证类型。 |
4280| DOMAIN<sup>9+</sup>  | 1024     | 表示域认证类型。|
4281
4282## AuthSubType<sup>8+</sup>
4283
4284表示用于认证的凭据子类型的枚举。
4285
4286**系统接口:** 此接口为系统接口。
4287
4288**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4289
4290| 名称       | 值 | 说明               |
4291| ---------- | ----- | ------------------ |
4292| PIN_SIX    | 10000 | 表示6位凭证。       |
4293| PIN_NUMBER | 10001 | 表示自定义数字凭证。 |
4294| PIN_MIXED  | 10002 | 表示自定义混合凭据。 |
4295| FACE_2D    | 20000 | 表示2D 人脸凭证。   |
4296| FACE_3D    | 20001 | 表示3D 人脸凭证。   |
4297| FINGERPRINT_CAPACITIVE<sup>10+</sup>    | 30000 | 表示电容式指纹。   |
4298| FINGERPRINT_OPTICAL<sup>10+</sup>    | 30001 | 表示光学指纹。   |
4299| FINGERPRINT_ULTRASONIC<sup>10+</sup>    | 30002 | 表示超声波指纹。   |
4300| DOMAIN_MIXED<sup>9+</sup>    | 10240001 | 表示域认证混合凭证。   |
4301
4302## AuthTrustLevel<sup>8+</sup>
4303
4304表示认证结果的受信任级别的枚举。
4305
4306**系统接口:** 此接口为系统接口。
4307
4308**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4309
4310| 名称  | 值 | 说明        |
4311| ---- | ------ | ----------- |
4312| ATL1 | 10000  | 信任级别 1。 |
4313| ATL2 | 20000  | 信任级别 2。 |
4314| ATL3 | 30000  | 信任级别 3。 |
4315| ATL4 | 40000  | 信任级别 4。 |
4316
4317## Module<sup>8+</sup>
4318
4319表示获取信息的模块的枚举。
4320
4321**系统接口:** 此接口为系统接口。
4322
4323**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4324
4325| 名称       | 值 | 说明                     |
4326| --------- | ------ | ------------------------ |
4327| FACE_AUTH | 1      | 表示从人脸认证获取的信息。 |
4328
4329## ResultCode<sup>8+</sup>
4330
4331表示身份验证结果码。
4332
4333**系统接口:** 此接口为系统接口。
4334
4335**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4336
4337| 名称                    | 值 | 说明                                     |
4338| ----------------------- | ----- | ---------------------------------------- |
4339| SUCCESS                 | 0     | 表示身份验证成功或支持此功能。             |
4340| FAIL                    | 1     | 表示验证器无法识别用户。                   |
4341| GENERAL_ERROR           | 2     | 表示其他错误。                            |
4342| CANCELED                | 3     | 表示身份验证已取消。                       |
4343| TIMEOUT                 | 4     | 表示身份验证已超时。                       |
4344| TYPE_NOT_SUPPORT        | 5     | 表示不支持此身份验证类型。                 |
4345| TRUST_LEVEL_NOT_SUPPORT | 6     | 表示不支持身份验证信任级别。               |
4346| BUSY                    | 7     | 表示身份验证任务正忙。等待几秒钟,然后重试。 |
4347| INVALID_PARAMETERS      | 8     | 表示参数不正确。                          |
4348| LOCKED                  | 9     | 指示身份验证器已锁定。                     |
4349| NOT_ENROLLED            | 10    | 表示用户尚未注册验证器。                   |
4350
4351## FaceTipsCode<sup>8+</sup>
4352
4353表示人脸验证过程中提示的枚举。
4354
4355**系统接口:** 此接口为系统接口。
4356
4357**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4358
4359| 名称                          | 值 | 说明                                     |
4360| ----------------------------- | ----- | ---------------------------------------- |
4361| FACE_AUTH_TIP_TOO_BRIGHT      | 1     | 表示由于高照明,获得的面部图像太亮。         |
4362| FACE_AUTH_TIP_TOO_DARK        | 2     | 表示由于照明度低,获得的面部图像太暗。       |
4363| FACE_AUTH_TIP_TOO_CLOSE       | 3     | 表示面部离设备太近。                       |
4364| FACE_AUTH_TIP_TOO_FAR         | 4     | 表示面部离设备太远。                       |
4365| FACE_AUTH_TIP_TOO_HIGH        | 5     | 表示设备太高,仅捕捉面部上部。              |
4366| FACE_AUTH_TIP_TOO_LOW         | 6     | 表示设备太低,仅捕捉面部下部。              |
4367| FACE_AUTH_TIP_TOO_RIGHT       | 7     | 指示设备向右偏移,并且仅捕捉面部的右侧部分。 |
4368| FACE_AUTH_TIP_TOO_LEFT        | 8     | 指示设备向左偏移,并且仅捕捉面部的左侧部分。 |
4369| FACE_AUTH_TIP_TOO_MUCH_MOTION | 9     | 表示面部信息收集过程中面部移动过快。         |
4370| FACE_AUTH_TIP_POOR_GAZE       | 10    | 表示面未朝向设备。                         |
4371| FACE_AUTH_TIP_NOT_DETECTED    | 11    | 表示未检测到人脸。                         |
4372
4373## FingerprintTips<sup>8+</sup>
4374
4375表示指纹身份验证过程中提示的枚举。
4376
4377**系统接口:** 此接口为系统接口。
4378
4379**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount
4380
4381| 名称                          | 值 | 说明                                            |
4382| ----------------------------- | ----- | ----------------------------------------------- |
4383| FINGERPRINT_TIP_GOOD          | 0     | 表示采集的图像良好。                              |
4384| FINGERPRINT_TIP_IMAGER_DIRTY  | 1     | 表示由于传感器上可疑或检测到污垢,指纹图像噪声过大。 |
4385| FINGERPRINT_TIP_INSUFFICIENT  | 2     | 表示由于检测到的情况,指纹图像噪声太大,无法处理。   |
4386| FINGERPRINT_TIP_PARTIAL       | 3     | 表示仅检测到部分指纹图像。                         |
4387| FINGERPRINT_TIP_TOO_FAST      | 4     | 表示指纹图像由于快速运动而不完整。                  |
4388| FINGERPRINT_TIP_TOO_SLOW      | 5     | 表示由于缺少运动,指纹图像无法读取。                |
4389| FINGERPRINT_TIP_FINGER_DOWN<sup>10+</sup>   | 6     | 表示手指落下。                  |
4390| FINGERPRINT_TIP_FINGER_UP<sup>10+</sup>     | 7     | 表示手指抬起。                |
4391
4392## DomainAccountInfo<sup>8+</sup>
4393
4394表示域帐号信息。
4395
4396**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount4397
4398| 名称      | 类型   | 必填 | 说明       |
4399| ----------- | ------ | ---- | ---------- |
4400| accountId<sup>10+</sup> | string | 否   | 域帐号标识。<br>**系统接口:** 此接口为系统接口,默认为空。 |
4401| isAuthenticated<sup>11+</sup>| boolean | 否 | 指示域账号是否已认证。<br>**系统接口:** 此接口为系统接口,默认为false。|
4402
4403## ConstraintSourceTypeInfo<sup>9+</sup>
4404
4405表示约束来源类型信息。
4406
4407**系统接口:** 此接口为系统接口。
4408
4409**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount4410
4411| 名称      | 类型   | 必填 | 说明       |
4412| ----------- | ------ | ---- | ---------- |
4413| localId      | number | 是   | 系统帐号ID     |
4414| type | [ConstraintSourceType](#constraintsourcetype9) | 是   | 约束来源类型 |
4415
4416## ConstraintSourceType<sup>9+</sup>
4417
4418表示约束来源类型的枚举。
4419
4420**系统接口:** 此接口为系统接口。
4421
4422**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount4423
4424| 名称   | 值 | 说明         |
4425| ------ | ------ | ------------ |
4426| CONSTRAINT_NOT_EXIST  | 0      | 约束不存在 |
4427| CONSTRAINT_TYPE_BASE | 1      | 约束源自系统设置   |
4428| CONSTRAINT_TYPE_DEVICE_OWNER  | 2   | 约束源自设备所有者设置   |
4429| CONSTRAINT_TYPE_PROFILE_OWNER  | 3  | 约束源自资料所有者设置   |
4430
4431## AuthStatusInfo<sup>10+</sup>
4432
4433表示认证状态信息。
4434
4435**系统接口:** 此接口为系统接口。
4436
4437**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount4438
4439| 名称      | 类型   | 必填 | 说明       |
4440| ----------- | ------ | ---- | ---------- |
4441| remainTimes  | number | 是   | 剩余次数   |
4442| freezingTime | number | 是   | 冻结时间 |
4443
4444## GetDomainAccessTokenOptions<sup>10+</sup>
4445
4446表示获取域访问令牌的选项。
4447
4448**系统接口:** 此接口为系统接口。
4449
4450**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount4451
4452| 名称      | 类型   | 必填 | 说明       |
4453| ----------- | ------ | ---- | ---------- |
4454| domainAccountInfo  | [DomainAccountInfo](#domainaccountinfo8) | 是   | 域帐号的信息   |
4455| domainAccountToken | Uint8Array | 是   | 域帐号的令牌 |
4456| businessParams | Record<string, Object> | 是   | 业务参数,由业务方根据请求协议自定义 |
4457| callerUid | number | 是   | 调用方唯一标识符 |
4458
4459## GetDomainAccountInfoOptions<sup>10+</sup>
4460
4461表示查询域帐号信息的选项。
4462
4463**系统接口:** 此接口为系统接口。
4464
4465**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount4466
4467| 名称      | 类型   | 必填 | 说明       |
4468| ----------- | ------ | ---- | ---------- |
4469| accountName | string | 是   | 域帐号名。 |
4470| domain      | string | 否   | 域名。     |
4471
4472## GetDomainAccountInfoPluginOptions<sup>10+</sup>
4473
4474表示插件查询域帐号信息的选项。GetDomainAccountInfoPluginOptions类继承[GetDomainAccountInfoOptions](#getdomainaccountinfooptions10)
4475
4476**系统接口:** 此接口为系统接口。
4477
4478**系统能力:** 以下各项对应的系统能力均为SystemCapability.Account.OsAccount4479
4480| 名称      | 类型   | 必填 | 说明       |
4481| ----------- | ------ | ---- | ---------- |
4482| callerUid | number | 是   | 调用方唯一标识符 |
4483