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