AWS SDK Version 3 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Temporary, short-lived session credentials that are automatically retrieved from Amazon Cognito Identity Service and AWS Security Token Service. Depending on configured Logins, credentials may be authenticated or unauthenticated.

Inheritance Hierarchy

System.Object
  Amazon.Runtime.AWSCredentials
    Amazon.Runtime.RefreshingAWSCredentials
      Amazon.CognitoIdentity.CognitoAWSCredentials

Namespace: Amazon.CognitoIdentity
Assembly: AWSSDK.CognitoIdentity.dll
Version: 3.x.y.z

Syntax

C#
public class CognitoAWSCredentials : RefreshingAWSCredentials
         IDisposable

The CognitoAWSCredentials type exposes the following members

Constructors

NameDescription
Public Method CognitoAWSCredentials(string, RegionEndpoint)

Constructs a new CognitoAWSCredentials instance, which will use the specified Amazon Cognito identity pool to get short lived session credentials.

Public Method CognitoAWSCredentials(string, string, string, string, RegionEndpoint)

Constructs a new CognitoAWSCredentials instance, which will use the specified Amazon Cognito identity pool to make a requests to the AWS Security Token Service (STS) to request short lived session credentials.

Public Method CognitoAWSCredentials(string, string, string, string, IAmazonCognitoIdentity, IAmazonSecurityTokenService)

Constructs a new CognitoAWSCredentials instance, which will use the specified Amazon Cognito identity pool to make a requests to the AWS Security Token Service (STS) to request short lived session credentials.

Properties

NameTypeDescription
Public Property AccountId System.String

The AWS accountId for the account with Amazon Cognito

Public Property AuthRoleArn System.String

The ARN of the IAM Role that will be assumed when authenticated

Public Property CurrentLoginProviders System.String[]

The list of current providers that are used for authenticated credentials.

Public Property IdentityPoolId System.String

The Amazon Cogntio identity pool to use

Public Property LoginsCount System.Int32

Returns count of Login Providers.

Public Property PreemptExpiryTime System.TimeSpan Inherited from Amazon.Runtime.RefreshingAWSCredentials.
Public Property UnAuthRoleArn System.String

The ARN of the IAM Role that will be assumed when unauthenticated

Methods

Note:

Asynchronous operations (methods ending with Async) in the table below are for .NET 4.5 or higher. For .NET 3.5 the SDK follows the standard naming convention of BeginMethodName and EndMethodName to indicate asynchronous operations - these method pairs are not shown in the table below.

NameDescription
Public Method AddLogin(string, string)

Adds a login to be used for authenticated requests.

Public Method CacheCredentials(RefreshingAWSCredentials.CredentialsRefreshState)

Caches the credentials to player pref's

Public Method CacheIdentityId(string)

Caches the identity id retrieved from Cognito.

For the Windows Phone and Windows Store version of the SDK the identity id is stored in the Windows.Storage.ApplicationData.Current.LocalSettings or Windows.Storage.ApplicationData.Current.RoamingSettings depending on the IdentityIdCacheMode property.

For the base .NET 3.5 and .NET 4.5 version of the SDK the identity id is not cached. To support caching the CacheIdentityId, GetCachedIdentityId and ClearIdentityCache methods need to be overridden.

Public Method Clear()

Clears current credentials state. This will reset the IdentityId. Use Amazon.Runtime.RefreshingAWSCredentials.ClearCredentials instead if you just want to trigger a credentials refresh.

Public Method ClearCredentials() Inherited from Amazon.Runtime.RefreshingAWSCredentials.
Public Method ClearIdentityCache()

Clears the currently identity id from the cache.

For the base .NET 3.5 and .NET 4.5 version of the SDK the identity id is not cached. To support caching the CacheIdentityId, GetCachedIdentityId and ClearIdentityCache methods need to be overridden.

Public Method ContainsProvider(string)

Returns if the providerName is present in the Logins Collection.

Public Method Dispose() Inherited from Amazon.Runtime.RefreshingAWSCredentials.
Public Method GetCachedCredentials()

Gets the cached credentials state

Public Method GetCachedIdentityId()

Gets the previously cached the identity id retrieved from Cognito.

For the Windows Phone and Windows Store version of the SDK the identity id is stored in the Windows.Storage.ApplicationData.Current.LocalSettings or Windows.Storage.ApplicationData.Current.RoamingSettings depending on the IdentityIdCacheMode property. By default IdentityIdCacheMode will be set LocalSettings.

For the base .NET 3.5 and .NET 4.5 version of the SDK the identity id is not cached. To support caching the CacheIdentityId, GetCachedIdentityId and ClearIdentityCache methods need to be overridden.

Public Method GetCredentials() Inherited from Amazon.Runtime.RefreshingAWSCredentials.
Public Method GetCredentialsAsync() Inherited from Amazon.Runtime.RefreshingAWSCredentials.
Public Method GetIdentityId()

Gets the Identity Id corresponding to the credentials retrieved from Cognito. Note: this setting may change during execution. To be notified of its new value, attach a listener to IdentityChangedEvent

Public Method GetIdentityIdAsync()

Gets the Identity Id corresponding to the credentials retrieved from Cognito. Note: this setting may change during execution. To be notified of its new value, attach a listener to IdentityChangedEvent

Public Method RefreshIdentityAsync()

Provides a way to override fetching the identity in case of developer authenticated identities. The default behaviour will be using Cognito to retrieve the identity id.

Public Method RemoveLogin(string)

Removes a provider from the collection of logins.

Events

NameDescription
Event IdentityChangedEvent

Version Information

.NET Core App:
Supported in: 3.1

.NET Standard:
Supported in: 2.0

.NET Framework:
Supported in: 4.5, 4.0, 3.5