# 账号子系统JS API变更 OpenHarmony 3.1 Release版本相较于OpenHarmony 3.0 LTS版本,账号子系统的API变更如下: ## 接口变更 | 模块名 | 类名 | 方法/属性/枚举/常量 | 变更类型 | |---|---|---|---| | ohos.account.osAccount | OsAccountType | GUEST | 新增 | | ohos.account.osAccount | OsAccountType | NORMAL | 新增 | | ohos.account.osAccount | OsAccountType | ADMIN = 0 | 新增 | | ohos.account.osAccount | DomainAccountInfo | accountName: string; | 新增 | | ohos.account.osAccount | DomainAccountInfo | domain: string; | 新增 | | ohos.account.osAccount | OsAccountInfo | domainInfo: DomainAccountInfo; | 新增 | | ohos.account.osAccount | OsAccountInfo | distributedInfo: distributedAccount.DistributedInfo; | 新增 | | ohos.account.osAccount | OsAccountInfo | isCreateCompleted: boolean; | 新增 | | ohos.account.osAccount | OsAccountInfo | isActived: boolean; | 新增 | | ohos.account.osAccount | OsAccountInfo | serialNumber: number; | 新增 | | ohos.account.osAccount | OsAccountInfo | lastLoginTime: number; | 新增 | | ohos.account.osAccount | OsAccountInfo | createTime: number; | 新增 | | ohos.account.osAccount | OsAccountInfo | photo: string; | 新增 | | ohos.account.osAccount | OsAccountInfo | isVerified: boolean; | 新增 | | ohos.account.osAccount | OsAccountInfo | constraints: Array; | 新增 | | ohos.account.osAccount | OsAccountInfo | type: OsAccountType; | 新增 | | ohos.account.osAccount | OsAccountInfo | localName: string; | 新增 | | ohos.account.osAccount | OsAccountInfo | localId: number; | 新增 | | ohos.account.osAccount | AccountManager | getSerialNumberByOsAccountLocalId(localId: number, callback: AsyncCallback): void;
getSerialNumberByOsAccountLocalId(localId: number): Promise; | 新增 | | ohos.account.osAccount | AccountManager | getOsAccountLocalIdBySerialNumber(serialNumber: number, callback: AsyncCallback): void;
getOsAccountLocalIdBySerialNumber(serialNumber: number): Promise; | 新增 | | ohos.account.osAccount | AccountManager | getDistributedVirtualDeviceId(callback: AsyncCallback): void;
getDistributedVirtualDeviceId(): Promise; | 新增 | | ohos.account.osAccount | AccountManager | getOsAccountTypeFromProcess(callback: AsyncCallback): void;
getOsAccountTypeFromProcess(): Promise; | 新增 | | ohos.account.osAccount | AccountManager | queryCurrentOsAccount(callback: AsyncCallback): void;
queryCurrentOsAccount(): Promise; | 新增 | | ohos.account.osAccount | AccountManager | queryActivatedOsAccountIds(callback: AsyncCallback>): void;
queryActivatedOsAccountIds(): Promise>; | 新增 | | ohos.account.osAccount | AccountManager | getOsAccountAllConstraints(localId: number, callback: AsyncCallback>): void;
getOsAccountAllConstraints(localId: number): Promise>; | 新增 | | ohos.account.osAccount | AccountManager | getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo, callback: AsyncCallback): void;
getOsAccountLocalIdFromDomain(domainInfo: DomainAccountInfo): Promise; | 新增 | | ohos.account.osAccount | AccountManager | getOsAccountLocalIdFromUid(uid: number, callback: AsyncCallback): void;
getOsAccountLocalIdFromUid(uid: number): Promise; | 新增 | | ohos.account.osAccount | AccountManager | getOsAccountLocalIdFromProcess(callback: AsyncCallback): void;
getOsAccountLocalIdFromProcess(): Promise; | 新增 | | ohos.account.osAccount | AccountManager | getCreatedOsAccountsCount(callback: AsyncCallback): void;
getCreatedOsAccountsCount(): Promise; | 新增 | | ohos.account.osAccount | AccountManager | isOsAccountVerified(callback: AsyncCallback): void;
isOsAccountVerified(localId: number, callback: AsyncCallback): void;
isOsAccountVerified(localId?: number): Promise; | 新增 | | ohos.account.osAccount | AccountManager | isTestOsAccount(callback: AsyncCallback): void;
isTestOsAccount(): Promise; | 新增 | | ohos.account.osAccount | AccountManager | isOsAccountConstraintEnable(localId: number, constraint: string, callback: AsyncCallback): void;
isOsAccountConstraintEnable(localId: number, constraint: string): Promise; | 新增 | | ohos.account.osAccount | AccountManager | isOsAccountActived(localId: number, callback: AsyncCallback): void;
isOsAccountActived(localId: number): Promise; | 新增 | | ohos.account.osAccount | AccountManager | isMultiOsAccountEnable(callback: AsyncCallback): void;
isMultiOsAccountEnable(): Promise; | 新增 | | ohos.account.osAccount | osAccount | function getAccountManager(): AccountManager; | 新增 | | ohos.account.appAccount | Authenticator | authenticate(name: string, authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; | 新增 | | ohos.account.appAccount | Authenticator | addAccountImplicitly(authType: string, callerBundleName: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; | 新增 | | ohos.account.appAccount | AuthenticatorCallback | onRequestRedirected: (request: Want) => void; | 新增 | | ohos.account.appAccount | AuthenticatorCallback | onResult: (code: number, result: {[key: string]: any}) => void; | 新增 | | ohos.account.appAccount | ResultCode | ERROR_PERMISSION_DENIED = 10018 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_UNSUPPORT_AUTH_TYPE = 10017 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_UNSUPPORT_ACTION = 10016 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_TOKEN_TOO_MANY = 10015 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_TOKEN_NOT_EXIST = 10014 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_TIMEOUT = 10013 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_SESSION_NOT_EXIST = 10012 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_SERVICE_EXCEPTION = 10011 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_SERVICE_BUSY = 10010 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_LIST_TOO_LARGE = 10009 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_CANCELED = 10008 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_OAUTH_AUTHENTICATOR_NOT_EXIST = 10007 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_NETWORK_EXCEPTION = 10006 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_INVALID_RESPONSE = 10005 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_INVALID_REQUEST = 10004 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_INVALID_PASSWORD = 10003 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_APP_ACCOUNT_SERVICE_EXCEPTION = 10002 | 新增 | | ohos.account.appAccount | ResultCode | ERROR_ACCOUNT_NOT_EXIST = 10001 | 新增 | | ohos.account.appAccount | ResultCode | SUCCESS = 0 | 新增 | | ohos.account.appAccount | Constants | KEY_CALLER_BUNDLE_NAME = "callerBundleName" | 新增 | | ohos.account.appAccount | Constants | KEY_CALLER_UID = "callerUid" | 新增 | | ohos.account.appAccount | Constants | KEY_CALLER_PID = "callerPid" | 新增 | | ohos.account.appAccount | Constants | KEY_SESSION_ID = "sessionId" | 新增 | | ohos.account.appAccount | Constants | KEY_AUTH_TYPE = "authType" | 新增 | | ohos.account.appAccount | Constants | KEY_ACTION = "action" | 新增 | | ohos.account.appAccount | Constants | KEY_TOKEN = "token" | 新增 | | ohos.account.appAccount | Constants | KEY_OWNER = "owner" | 新增 | | ohos.account.appAccount | Constants | KEY_NAME = "name" | 新增 | | ohos.account.appAccount | Constants | ACTION_AUTHENTICATE = "authenticate" | 新增 | | ohos.account.appAccount | Constants | ACTION_ADD_ACCOUNT_IMPLICITLY = "addAccountImplicitly" | 新增 | | ohos.account.appAccount | AuthenticatorInfo | labelId: number; | 新增 | | ohos.account.appAccount | AuthenticatorInfo | iconId: number; | 新增 | | ohos.account.appAccount | AuthenticatorInfo | owner: string; | 新增 | | ohos.account.appAccount | OAuthTokenInfo | token: string; | 新增 | | ohos.account.appAccount | OAuthTokenInfo | authType: string; | 新增 | | ohos.account.appAccount | AppAccountInfo | name: string; | 新增 | | ohos.account.appAccount | AppAccountInfo | owner: string; | 新增 | | ohos.account.appAccount | AppAccountManager | getAuthenticatorInfo(owner: string, callback: AsyncCallback): void;
getAuthenticatorInfo(owner: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | getAuthenticatorCallback(sessionId: string, callback: AsyncCallback): void;
getAuthenticatorCallback(sessionId: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | getOAuthList(name: string, authType: string, callback: AsyncCallback>): void;
getOAuthList(name: string, authType: string): Promise>; | 新增 | | ohos.account.appAccount | AppAccountManager | getAllOAuthTokens(name: string, owner: string, callback: AsyncCallback>): void;
getAllOAuthTokens(name: string, owner: string): Promise>; | 新增 | | ohos.account.appAccount | AppAccountManager | checkOAuthTokenVisibility(name: string, authType: string, bundleName: string, callback: AsyncCallback): void;
checkOAuthTokenVisibility(name: string, authType: string, bundleName: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean, callback: AsyncCallback): void;
setOAuthTokenVisibility(name: string, authType: string, bundleName: string, isVisible: boolean): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | deleteOAuthToken(name: string, owner: string, authType: string, token: string, callback: AsyncCallback): void;
deleteOAuthToken(name: string, owner: string, authType: string, token: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | setOAuthToken(name: string, authType: string, token: string, callback: AsyncCallback): void;
setOAuthToken(name: string, authType: string, token: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | getOAuthToken(name: string, owner: string, authType: string, callback: AsyncCallback): void;
getOAuthToken(name: string, owner: string, authType: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | authenticate(name: string, owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; | 新增 | | ohos.account.appAccount | AppAccountManager | off(type: 'change', callback?: Callback>): void; | 新增 | | ohos.account.appAccount | AppAccountManager | on(type: 'change', owners: Array, callback: Callback>): void; | 新增 | | ohos.account.appAccount | AppAccountManager | getAssociatedData(name: string, key: string, callback: AsyncCallback): void;
getAssociatedData(name: string, key: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | getAccountExtraInfo(name: string, callback: AsyncCallback): void;
getAccountExtraInfo(name: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | getAccountCredential(name: string, credentialType: string, callback: AsyncCallback): void;
getAccountCredential(name: string, credentialType: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | getAllAccounts(owner: string, callback: AsyncCallback>): void;
getAllAccounts(owner: string): Promise>; | 新增 | | ohos.account.appAccount | AppAccountManager | getAllAccessibleAccounts(callback: AsyncCallback>): void;
getAllAccessibleAccounts(): Promise>; | 新增 | | ohos.account.appAccount | AppAccountManager | setAssociatedData(name: string, key: string, value: string, callback: AsyncCallback): void;
setAssociatedData(name: string, key: string, value: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | setAppAccountSyncEnable(name: string, isEnable: boolean, callback: AsyncCallback): void;
setAppAccountSyncEnable(name: string, isEnable: boolean): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | setAccountExtraInfo(name: string, extraInfo: string, callback: AsyncCallback): void;
setAccountExtraInfo(name: string, extraInfo: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | setAccountCredential(name: string, credentialType: string, credential: string, callback: AsyncCallback): void;
setAccountCredential(name: string, credentialType: string, credential: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | checkAppAccountSyncEnable(name: string, callback: AsyncCallback): void;
checkAppAccountSyncEnable(name: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | enableAppAccess(name: string, bundleName: string, callback: AsyncCallback): void;
enableAppAccess(name: string, bundleName: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | disableAppAccess(name: string, bundleName: string, callback: AsyncCallback): void;
disableAppAccess(name: string, bundleName: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | deleteAccount(name: string, callback: AsyncCallback): void;
deleteAccount(name: string): Promise; | 新增 | | ohos.account.appAccount | AppAccountManager | addAccountImplicitly(owner: string, authType: string, options: {[key: string]: any}, callback: AuthenticatorCallback): void; | 新增 | | ohos.account.appAccount | AppAccountManager | addAccount(name: string, callback: AsyncCallback): void;
addAccount(name: string, extraInfo: string, callback: AsyncCallback): void;
addAccount(name: string, extraInfo?: string): Promise; | 新增 | | ohos.account.appAccount | appAccount | function createAppAccountManager(): AppAccountManager; | 新增 |