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