Skip to content

OAuthApplicationCredential Class

  • OAuthApplicationCredential
  • class Esri::ArcGISRuntime::Authentication::OAuthApplicationCredential

    A credential to access OAuth token-secured ArcGIS resources using the application's credentials. More...

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

    Public Functions

    virtual ~OAuthApplicationCredential() override
    QString clientId() const
    QUrl portalUrl() const
    std::optional<int> tokenExpirationInterval() const
    QFuture<Esri::ArcGISRuntime::Authentication::OAuthApplicationTokenInfo *> tokenInfoAsync(QObject *parent = nullptr)

    Static Public Members

    QFuture<Esri::ArcGISRuntime::Authentication::OAuthApplicationCredential *> createAsync(const QUrl &portalUrl, const QString &clientId, const QString &clientSecret, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)

    Detailed Description

    The OAuth application credential generates a short-lived access token that gives your application permission to access token-secured ArcGIS content and services, such as the ArcGIS location services.

    The OAuthApplicationCredential requires a private `client secret`. It is important to treat this as you would your password. You must keep it confidential and we recommended not storing in your application.

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

    See also Register Your Application.

    Member Function Documentation

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

    Destructor.

    QString OAuthApplicationCredential::clientId() const

    Returns a unique identifier associated with an application registered with the portal that assists with client/server OAuth authentication.

    [static] QFuture<Esri::ArcGISRuntime::Authentication::OAuthApplicationCredential *> OAuthApplicationCredential::createAsync(const QUrl &portalUrl, const QString &clientId, const QString &clientSecret, std::optional<int> tokenExpirationInterval, QObject *parent = nullptr)

    Creates an OAuthApplicationCredential with information needed to access an ArcGIS resource.

    • portalUrl - The URL of the portal to authenticate with.
    • clientId - A unique identifier associated with an application registered with the portal that assists with client/server OAuth authentication.
    • clientSecret - A private key that verifies the application is authorized to access the registered service.
    • tokenExpirationInterval - The duration the token will remain valid, represented in minutes. The value must be greater than 0, otherwise the server default is used. Specify std::nullopt to use the server default.
    • parent - An optional parent.

    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.

    QUrl OAuthApplicationCredential::portalUrl() const

    Returns the URL of the portal to authenticate with.

    std::optional<int> OAuthApplicationCredential::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 20160 minutes (14 days), but this value can be configured on the server.

    QFuture<Esri::ArcGISRuntime::Authentication::OAuthApplicationTokenInfo *> OAuthApplicationCredential::tokenInfoAsync(QObject *parent = nullptr)

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

    Expired tokens are automatically regenerated while credentials remain valid.

    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.