Account QML Type

Representation of an online account. More...

Import Statement: import Lomiri.OnlineAccounts 2.0




Detailed Description

The Account object holds the information related to an account and provides methods to interact with it. It's not possible to create such objects from QML; instead, they are returned by the AccountModel in the account role or in the accountList property.

Here's an example on how to use the account object in a delegate:

import QtQuick 2.0
import Lomiri.OnlineAccounts 2.0

ListView {
    model: AccountModel {}
    delegate: Button {
        text: "Authenticate " + model.displayName
        onClicked: model.account.authenticate({})
        Connections {
            target: model.account
            onAuthenticationReply: {
                console.log("Access token is " + reply['AccessToken'])

Error codes used in this module

Some operations, such as the Account::authenticate() and the AccountModel::requestAccess() methods, can fail and return one of these error codes:

Property Documentation

accountId : int

Numeric identifier of the account. This property remains constant during the lifetime of the account. Note, however, that if the user deletes the account and re-creates it, its ID will be different.

authenticationMethod : enumeration

The authentication method used when authenticating with the account. Currently, these authentication methods are supported:

displayName : string

The display name of the account. This is usually the user's login name, but applications should not rely on the value of this property. Use it only for display purposes.

service : int

Service data associated with this account. This is an object containing the following properties:

serviceId : int

Identifier for the service used with the account.

settings : jsobject

A dictionary of the settings stored into the account.

valid : bool

Whether the account object is valid; this is usually true, because the AccountModel never gives out invalid accounts. However, it can happen that a valid account becomes invalid while the application is using it (if, for instance, the user deleted the account or revoked the application's access rights to use it). As soon as this property becomes false, the application should stop using this account.

Signal Documentation

authenticationReply(jsobject authenticationData)

Emitted when the authentication completes. The authenticationData object will contain the authentication reply. If the authentication failed, the following two keys will be present:

Method Documentation

void authenticate(jsobject params)

Perform the authentication on this account. The params parameter can be used to pass authentication data, such as the ClientId and ClientSecret used in the OAuth flow. The list of the supported authentication parameters depend on the authentication method being used, and are documented in the Online Accounts development Guide in the UBports Developer Portal.

There are, however, two authentication parameters which are available regardless of the authentication method being used:

Each call to this method will cause the authenticationReply signal to be emitted at some time later. Note that the authentication might involve interactions with the network or with the end-user, so don't expect a reply to be emitted immediately.

See also authenticationReply.