AWSCognitoCredentialsProvider Class Reference
| Inherits from | NSObject |
|---|---|
| Conforms to | AWSCredentialsProvider |
| Declared in | AWSCredentialsProvider.h AWSCredentialsProvider.m |
Overview
An AWSCredentialsProvider that uses Amazon Cognito to fetch temporary credentials tied to an identity.
To learn more about Amazon Cognito, please visit https://aws.amazon.com/cognito.
There are 3 different flows supported by this credentials provider, see factory and init methods for choosing the right one for your use case:
- Enhanced flow: Uses Cognito for all operations and only requires an identity pool id to initialize.
- Basic flow: Uses Cognito + STS and requires identity pool plus IAM roles
- Developer authenticated identities: Uses your own AWSCognitoCredentialsProviderHelper to establish identity + Cognito (and optionally STS) to establish credentials.
Other Methods
– initWithRegionType:identityPoolId:
Initializer for credentials provider with enhanced authentication flow. This is the recommended constructor for first time Amazon Cognito developers. Will create an instance of AWSEnhancedCognitoIdentityProvider.
- (instancetype)initWithRegionType:(AWSRegionType)regionType identityPoolId:(NSString *)identityPoolIdParameters
regionType |
The region in which your identity pool exists. |
|---|---|
identityPoolId |
The identity pool id for this provider. Value is used to communicate with Amazon Cognito as well as namespace values stored in the keychain. |
Declared In
AWSCredentialsProvider.h
– initWithRegionType:identityPoolId:identityProviderManager:
Initializer for credentials provider with enhanced authentication flow. This is the recommended method for first time Amazon Cognito developers. Will create an instance of AWSEnhancedCognitoIdentityProvider.
- (instancetype)initWithRegionType:(AWSRegionType)regionType identityPoolId:(NSString *)identityPoolId identityProviderManager:(nullable id<AWSIdentityProviderManager>)identityProviderManagerParameters
regionType |
The region in which your identity pool exists. |
|---|---|
identityPoolId |
The identity pool id for this provider. Value is used to communicate with Amazon Cognito as well as namespace values stored in the keychain. |
identityProviderManager |
An object that conforms to the |
Declared In
AWSCredentialsProvider.h
– initWithRegionType:identityProvider:
Initializer for credentials provider with pre-created AWSCognitoCredentialsProviderHelper. Use this method when using developer authenticated identities.
- (instancetype)initWithRegionType:(AWSRegionType)regionType identityProvider:(id<AWSCognitoCredentialsProviderHelper>)identityProviderParameters
regionType |
The region in which your identity pool exists. |
|---|---|
identityProvider |
Implementation of AWSCognitoCredentialsProviderHelper which is responsible for acquiring identity id and (optionally) OpenId Connect token. |
Declared In
AWSCredentialsProvider.h
– initWithRegionType:unauthRoleArn:authRoleArn:identityProvider:
Initializer for credentials provider with pre-created AWSCognitoCredentialsProviderHelper. Only use this method if you need to set your IAM roles client side and use developer authenticated identities
- (instancetype)initWithRegionType:(AWSRegionType)regionType unauthRoleArn:(NSString *)unauthRoleArn authRoleArn:(NSString *)authRoleArn identityProvider:(id<AWSCognitoCredentialsProviderHelper>)identityProviderParameters
regionType |
The region in which your identity pool exists. |
|---|---|
unauthRoleArn |
The role ARN to use when getting credentials for unauthenticated identities. Provider will check the |
authRoleArn |
The role ARN to use when getting credentials for authenticated identities. Provider will check the |
identityProvider |
Implementation of AWSCognitoCredentialsProviderHelper which is responsible for acquiring identity id and (optionally) OpenId Connect token. |
Declared In
AWSCredentialsProvider.h
– initWithRegionType:identityPoolId:unauthRoleArn:authRoleArn:identityProviderManager:
Initializer for credentials provider with basic auth flow. Only use this method if you still need to set your IAM roles client side. This method will create an instance of AWSBasicCognitoIdentityProvider.
- (instancetype)initWithRegionType:(AWSRegionType)regionType identityPoolId:(NSString *)identityPoolId unauthRoleArn:(nullable NSString *)unauthRoleArn authRoleArn:(nullable NSString *)authRoleArn identityProviderManager:(nullable id<AWSIdentityProviderManager>)identityProviderManagerParameters
regionType |
The region in which your identity pool exists. |
|---|---|
identityPoolId |
The identity pool id for this provider. Value is used to communicate with Amazon Cognito as well as namespace values stored in the keychain. |
unauthRoleArn |
The role ARN to use when getting credentials for unauthenticated identities. Provider will check the |
authRoleArn |
The role ARN to use when getting credentials for authenticated identities. Provider will check the |
identityProviderManager |
An object that conforms to the |
Declared In
AWSCredentialsProvider.h
– credentials
Asynchronously returns a valid AWS credentials or an error object if it cannot retrieve valid credentials. It should cache valid credentials as much as possible and refresh them when they are invalid.
- (AWSTask<AWSCredentials*> *)credentialsReturn Value
A valid AWS credentials or an error object describing the error.
Declared In
AWSCredentialsProvider.h
– invalidateCachedTemporaryCredentials
Invalidates the cached temporary AWS credentials. If the credentials provider does not cache temporary credentials, this operation is a no-op.
- (void)invalidateCachedTemporaryCredentialsDeclared In
AWSCredentialsProvider.h
– getIdentityId
Get/retrieve the identity id for this provider. If an identity id is already set on this provider, no remote call is made and the identity will be returned as a result of the AWSTask (the identityId is also available as a property). If no identityId is set on this provider, one will be retrieved from the service.
- (AWSTask<NSString*> *)getIdentityIdReturn Value
AWSTask
Declared In
AWSCredentialsProvider.h
– clearKeychain
Clear ALL saved values for this provider (identityId, credentials, logins).
- (void)clearKeychainDeclared In
AWSCredentialsProvider.h
– clearCredentials
Clear the cached AWS credentials for this provider.
- (void)clearCredentialsDeclared In
AWSCredentialsProvider.h
– identityPoolId
The identity pool id associated with this provider. Also used to create a namedspaced keychain area to store identity id and credentials.
- (NSString *)identityPoolIdDeclared In
AWSCredentialsProvider.h
– identityId
The identity id associated with this provider. This value will be fetched from the keychain at startup. If you do not want to reuse the existing identity id, you must call the clearKeychain method.
- (NSString *)identityIdDeclared In
AWSCredentialsProvider.h
Other Methods
identityProvider
The identityProvider which is responsible for establishing the identity id and (optionally) the open id token for use in the Amazon Cognito authflow.
@property (nonatomic, strong, readonly) id<AWSCognitoCredentialsProviderHelper> identityProviderDeclared In
AWSCredentialsProvider.h

