Skip To Content ArcGIS for Developers Sign In Dashboard

Credential Class

class Esri::ArcGISRuntime::Credential

A credential used for accessing secured ArcGIS services and portals. More...

Header: #include <Credential>
Since: Esri::ArcGISRuntime 100.0
Inherits: Esri::ArcGISRuntime::Object

This class was introduced in Esri::ArcGISRuntime 100.0.

Public Functions

Credential(const QSslConfiguration &sslConfig, QObject *parent = nullptr)
Credential(const Esri::ArcGISRuntime::OAuthClientInfo &clientInfo, QObject *parent = nullptr)
Credential(const QString &username, const QString &password, QObject *parent = nullptr)
Credential(QObject *parent = nullptr)
virtual ~Credential() override
QUrl authenticatingHost() const
Esri::ArcGISRuntime::AuthenticationType authenticationType() const
Esri::ArcGISRuntime::Credential *clone(QObject *parent = nullptr) const
bool isSslRequired() const
QString oAuthAuthorizationCode() const
Esri::ArcGISRuntime::OAuthClientInfo oAuthClientInfo() const
QString oAuthRefreshToken() const
QString password() const
QString referer() const
void setOAuthAuthorizationCode(const QString &oAuthAuthorizationCode)
void setOAuthClientInfo(const Esri::ArcGISRuntime::OAuthClientInfo &clientInfo)
void setOAuthRefreshToken(const QString &oAuthRefreshToken)
void setSslConfiguration(const QSslConfiguration &sslConfig)
void setTokenServiceUrl(const QUrl &tokenServiceUrl)
void setUserAccount(const QString &username, const QString &password)
void setUserToken(const QString &token, const QString &referer, const QDateTime &tokenExpiry = QDateTime())
QSslConfiguration sslConfiguration() const
QString token() const
QDateTime tokenExpiry() const
QUrl tokenServiceUrl() const
QString username() const
bool operator==(const Esri::ArcGISRuntime::Credential &other) const

Detailed Description

A credential is composed of user account information (username and password), OAuth client information (OAuthClientInfo), or a secured token.

HTTP basic and digest authentication is supported.

Client certificate authentication is also supported for certificate secured resources. Load the certificate information into QSslConfiguration and construct a credential by providing it the SSL configuration.

See also OAuthClientInfo.

Member Function Documentation

Credential::Credential(const QSslConfiguration &sslConfig, QObject *parent = nullptr)

Construct Credential from a sslConfig with an optional parent.

Credential::Credential(const Esri::ArcGISRuntime::OAuthClientInfo &clientInfo, QObject *parent = nullptr)

Construct Credential from a clientInfo with an optional parent.

Credential::Credential(const QString &username, const QString &password, QObject *parent = nullptr)

Construct Credential from a username and password with an optional parent.

Credential::Credential(QObject *parent = nullptr)

Default constructor with an optional parent.

[override virtual] Credential::~Credential()


QUrl Credential::authenticatingHost() const

Returns the host (including port number) that a username/password will be sent to for authentication.

This is useful to display to a user when prompting them for a credential when a resource fails to load.

Esri::ArcGISRuntime::AuthenticationType Credential::authenticationType() const

Returns the authentication type that was used for the credential.

This is the authentication type requested by a secure service.

Esri::ArcGISRuntime::Credential *Credential::clone(QObject *parent = nullptr) const

Returns a copy of this credential instance with an optional parent.

bool Credential::isSslRequired() const

Returns true if the token provider requires that this token should only be transmitted over HTTPS.

QString Credential::oAuthAuthorizationCode() const

Returns the OAuth authorization code used for generating a user access token.

See also setOAuthAuthorizationCode().

Esri::ArcGISRuntime::OAuthClientInfo Credential::oAuthClientInfo() const

Returns the OAuth client information used for OAuth authentication to identify a registered application.

See also setOAuthClientInfo().

QString Credential::oAuthRefreshToken() const

Returns the OAuth refresh token used for generating a new user access token after the old one expires.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also setOAuthRefreshToken().

QString Credential::password() const

Returns the password.

QString Credential::referer() const

Returns a string representing the referer for which the long-lived token was generated.

void Credential::setOAuthAuthorizationCode(const QString &oAuthAuthorizationCode)

Sets the oAuthAuthorizationCode to be used to generate a user access token.

See also oAuthAuthorizationCode().

void Credential::setOAuthClientInfo(const Esri::ArcGISRuntime::OAuthClientInfo &clientInfo)

Sets the OAuth clientInfo for use with OAuth secured services.

See also oAuthClientInfo().

void Credential::setOAuthRefreshToken(const QString &oAuthRefreshToken)

Sets the oAuthRefreshToken to be used to generate a new user access token after the old one expires.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also oAuthRefreshToken().

void Credential::setSslConfiguration(const QSslConfiguration &sslConfig)

Sets this credential's SSL configuration to be sslConfig.

Any network request (QNetworkRequest) which consumes this credential will apply the provided SSL configuration.

The settings that apply are the private key, the local certificate, the SSL protocol (SSLv2, SSLv3, TLSv1.0 where applicable), the CA certificates and the ciphers that the SSL backend is allowed to use.

By default, no SSL configuration is set, which allows a connection to an ArcGIS service or portal to choose what configuration is best for the connection.

See also sslConfiguration().

void Credential::setTokenServiceUrl(const QUrl &tokenServiceUrl)

Sets the tokenServiceUrl to a remote token service if it is different from the default ArcGIS token service.

See also tokenServiceUrl().

void Credential::setUserAccount(const QString &username, const QString &password)

Sets the username and password for accessing a secured service or task.

If either username or password is empty, the change will not be applied.

void Credential::setUserToken(const QString &token, const QString &referer, const QDateTime &tokenExpiry = QDateTime())

Sets the user token, referer, and optional tokenExpiry for accessing a secured service or task.

The token is a secured token generated by an ArcGIS token service or a remote token service. Tokens are generated by sending an HTTP URL request to a token service endpoint or through an HTML page. Regardless of which option you choose, you must specify a clientID parameter to generate secured token. The clientID is typically the identity of the client application consuming the secured service.

The token and referer strings must not be empty or they will not be set properly.

QSslConfiguration Credential::sslConfiguration() const

Returns this credential's SSL configuration for a secured connection.

By default, no SSL settings are specified.

See also setSslConfiguration.

QString Credential::token() const

Returns the token.

The server that is running a secured service generates the token using a username/password combination.

QDateTime Credential::tokenExpiry() const

Returns the expiration date for the token credential.

The expiry date is expressed in UTC format.

QUrl Credential::tokenServiceUrl() const

Returns the remote token service's URL.

See also setTokenServiceUrl().

QString Credential::username() const

Returns the username.

bool Credential::operator==(const Esri::ArcGISRuntime::Credential &other) const

Returns true if this object is equal to other.

Feedback on this topic?