Skip To Content ArcGIS for Developers Sign In Dashboard

CredentialCache Class


A cache containing credentials to reuse. More...

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

Public Functions

Credential *credential(const QUrl &url) const
void removeAllCredentials()
bool removeCredential(const QUrl &url)
bool removeCredential(const Credential *credential)
bool setCredential(Credential *credential, const QUrl &url)
  • 31 public functions inherited from QObject

Additional Inherited Members

Detailed Description

A cache containing credentials to reuse.

An instance of this class is available through the AuthenticationManager. It represents a cache containing credentials. All objects and tasks share this instance and could potentially reuse a credential if they need to access the same security realm.

The URL acts as the lookup key into the cache and represents one of the following:

  • The full path to a server from an ArcGIS Server.
  • The full path to a portal, portal item, or hosted item.
  • The URL to a portal, such as
  • The URL to an ArcGIS Server instance, such as https://host(:port)/instance.

Automatic caching happens when credentials (that is, username, password, token, or OAuth client information) are required when connecting to a secure service hosted by ArcGIS Server, ArcGIS Online, or Federated by Portal. Upon successful connection to one of these secure services, the credential is cached in the CredentialCache and reused again whenever subsequent connections are made to the secure service.

Caching happens automatically if AuthenticationManager::isCredentialCacheEnabled is enabled. In addition, the CredentialCache class contains public methods to manipulate the cache contents.

Member Function Documentation



Credential *CredentialCache::credential(const QUrl &url) const

Returns the credential for a given url.

See also setCredential().

void CredentialCache::removeAllCredentials()

Removes all credentials from the cache.

bool CredentialCache::removeCredential(const QUrl &url)

Removes from the cache the credential for a given url and returns true if successful.

bool CredentialCache::removeCredential(const Credential *credential)

Removes from the cache the credential and returns true if successful.

bool CredentialCache::setCredential(Credential *credential, const QUrl &url)

Sets the credential for a given url and returns true if successful.

This method will append a credential to the cache if the key for the URL does not already exist. The credential is replaced for the URL if the URL is already in the cache.

See also credential().

Feedback on this topic?