Skip to content
  • TokenCredential
  • class Esri::ArcGISRuntime::Authentication::TokenCredential

    A credential that accesses token-secured ArcGIS content and services. More...

    Header: #include <Authentication/TokenCredential.h>
    Since: Esri::ArcGISRuntime 200.8
    Inherits: Esri::ArcGISRuntime::Authentication::ArcGISCredential

    Public Functions

    virtual ~TokenCredential() override
    std::optional<int> tokenExpirationInterval() const
    QFuture<Esri::ArcGISRuntime::Authentication::TokenInfo *> tokenInfoAsync(QObject *parent = nullptr)

    Static Public Members

    QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> createAsync(const QUrl &url, const QString &username, const QString &password, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)
    (since Esri::ArcGISRuntime 300.0) QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> createFederatedAsync(const QUrl &url, Esri::ArcGISRuntime::Authentication::ArcGISCredential *portalCredential, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)
    (since Esri::ArcGISRuntime 300.0) QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> createFederatedAsync(const QUrl &url, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)
    QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> createNetworkSecuredAsync(const QUrl &url, const QString &username, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)
    QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> createWithChallengeAsync(Esri::ArcGISRuntime::Authentication::ArcGISAuthenticationChallenge *challenge, const QString &username, const QString &password, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)

    Detailed Description

    To create a token credential, provide a secured service URL, valid case-sensitive username, and password. Alternatively, you can create a token credential for network secure resources that are secured using network authentication, such as Integrated Windows Authentication (IWA) or Public Key Infrastructure (PKI). In both cases, you can specify a token expiration in minutes.

    If you use this TokenCredential as part of the secure resource challenge handling, it will be stored in the ArcGISCredentialStore of the AuthenticationManager. It will be used by all subsequent requests that have a matching URL context.

    Member Function Documentation

    [override virtual noexcept] TokenCredential::~TokenCredential()

    Destructor.

    [static] QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> TokenCredential::createAsync(const QUrl &url, const QString &username, const QString &password, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)

    Creates a TokenCredential to access a secured ArcGIS resources, including portal, federated, and non-federated resources.

    • url - The URL of the token-secured resource.
    • username - The case-sensitive username used to access the secured resource or retrieve a token.
    • password - The password used to access the secured resource or retrieve a token.
    • tokenExpirationInterval - The duration the token will remain valid, represented in minutes. The value must be greater than 0, otherwise the server default is used.
    • parent - The optional parent QObject.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    [static, since Esri::ArcGISRuntime 300.0] QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> TokenCredential::createFederatedAsync(const QUrl &url, Esri::ArcGISRuntime::Authentication::ArcGISCredential *portalCredential, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)

    Creates a TokenCredential to access a secured federated ArcGIS resource.

    • url - The URL of the token-secured federated resource.
    • portalCredential - A credential for the portal with which the server hosting URL is federated. If not provided, the method retrieves one from ArcGISCredentialStore. If none is available, the creation of the federated credential will fail.
    • tokenExpirationInterval - The requested token validity duration, in minutes. If this value is omitted, or is less than or equal to zero, it defaults to the portal credential's token expiration interval. The server may shorten the requested duration based on its maximum token lifetime settings.
    • parent - The optional parent QObject.

    Federation is a security and administrative configuration in which an ArcGIS Server is registered with an ArcGIS Enterprise portal or ArcGIS Online organization, delegating authentication and authorization to the portal. This allows the portal to manage user identities, roles, and permissions for the server's services.

    This method creates a credential for a service directly using an existing portal credential, without relying on an authentication challenge or re-entering user credentials.

    - A valid portal credential is required to create a federated token credential. - Allows any ArcGISCredential type to be used as the portal credential. - If a portal credential is not provided and the ArcGISCredentialStore does not contain a credential for the federating portal, an error of type ErrorType::AuthenticationPortalCredentialMissing is returned. - If the provided portal credential does not match the portal with which the server is federated, an error of type ErrorType::AuthenticationCredentialCannotBeShared is returned. - If the provided URL is not federated with any portal, an error of type ErrorType::AuthenticationServiceNotFederated is returned.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    This function was introduced in Esri::ArcGISRuntime 300.0.

    [static, since Esri::ArcGISRuntime 300.0] QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> TokenCredential::createFederatedAsync(const QUrl &url, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)

    This function overloads createFederatedAsync.

    This function was introduced in Esri::ArcGISRuntime 300.0.

    [static] QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> TokenCredential::createNetworkSecuredAsync(const QUrl &url, const QString &username, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)

    Creates a TokenCredential with information needed to access an ArcGIS resource.

    • url - The URL of the network secured resource.
    • username - An optional case-sensitive username to associate with the credential. This value is informational only and can be an empty string.
    • tokenExpirationInterval - The duration the token will remain valid, represented in minutes. The value must be greater than 0, otherwise use std::nullopt to use the server default.
    • parent - The optional parent QObject.

    If the required network credential is not available in the network credential store, a network authentication challenge is expected to be issued.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    [static] QFuture<Esri::ArcGISRuntime::Authentication::TokenCredential *> TokenCredential::createWithChallengeAsync(Esri::ArcGISRuntime::Authentication::ArcGISAuthenticationChallenge *challenge, const QString &username, const QString &password, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)

    Creates a TokenCredential for a network secured ArcGIS resource.

    • challenge - An ArcGISAuthenticationChallenge object from which to construct the TokenCredential.
    • username - The case-sensitive username used to access the secured resource or retrieve a token.
    • password - The password used to access the secured resource or retrieve a token.
    • tokenExpirationInterval - The duration the token will remain valid, represented in minutes. The value must be greater than 0, otherwise the server default is used.
    • parent - The optional parent QObject.

    If the required network credential is not available in the network credential store, a network authentication challenge will be raised.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    std::optional<int> TokenCredential::tokenExpirationInterval() const

    Returns the length of time a token credential remains valid. Represented in minutes. If not explicitly set, the server default is used.

    If unspecified, the server returns a token with an expiration interval of 120 minutes (2 hours). The server default for the maximum allowed expiration time is 21600 minutes (15 days), but this value can be configured on the server.

    QFuture<Esri::ArcGISRuntime::Authentication::TokenInfo *> TokenCredential::tokenInfoAsync(QObject *parent = nullptr)

    Returns an instance of TokenInfo generated by this credential with an optional parent.

    If the token has expired, this method regenerates the access token. Token expiration is based on the tokenExpirationInterval.

    This method returns a QFuture for the asynchronous operation. Use future.then() to continue processing when the operation completes. Use future.onFailed() to handle exceptions of type ErrorException.

    See Working with QFuture for further details.

    Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.