Menu
Amazon Cognito
Developer Guide (Version Last Updated: 08/26/2017)

Accessing AWS Services

Once the Amazon Cognito credentials provider is initialized and refreshed, you can pass it directly to the initializer for an AWS client. For example, the following snippet initializes an Amazon DynamoDB client:

Android

Copy
// Create a service client with the provider AmazonDynamoDB client = new AmazonDynamoDBClient(credentialsProvider);

The credentials provider communicates with Amazon Cognito, retrieving both the unique identifier for authenticated and unauthenticated users as well as temporary, limited privilege AWS credentials for the AWS Mobile SDK. The retrieved credentials are valid for one hour, and the provider refreshes them when they expire.

iOS - Objective-C

Copy
// create a configuration that uses the provider AWSServiceConfiguration *configuration = [AWSServiceConfiguration configurationWithRegion:AWSRegionUSEast1 provider:credentialsProvider]; // get a client with the default service configuration AWSDynamoDB *dynamoDB = [AWSDynamoDB defaultDynamoDB];

The credentials provider communicates with Amazon Cognito, retrieving both the unique identifier for authenticated and unauthenticated users as well as temporary, limited privilege AWS credentials for the AWS Mobile SDK. The retrieved credentials are valid for one hour, and the provider refreshes them when they expire.

iOS - Swift

Copy
// get a client with the default service configuration let dynamoDB = AWSDynamoDB.default() // get a client with a custom configuration AWSDynamoDB.register(with: configuration!, forKey: "USWest2DynamoDB"); let dynamoDBCustom = AWSDynamoDB(forKey: "USWest2DynamoDB")

The credentials provider communicates with Amazon Cognito, retrieving both the unique identifier for authenticated and unauthenticated users as well as temporary, limited privilege AWS credentials for the AWS Mobile SDK. The retrieved credentials are valid for one hour, and the provider refreshes them when they expire.

JavaScript

Copy
// Create a service client with the provider var dynamodb = new AWS.DynamoDB({region: 'us-west-2'});

The credentials provider communicates with Amazon Cognito, retrieving both the unique identifier for authenticated and unauthenticated users as well as temporary, limited privilege AWS credentials for the AWS Mobile SDK. The retrieved credentials are valid for one hour, and the provider refreshes them when they expire.

Unity

Copy
// create a service client that uses credentials provided by Cognito AmazonDynamoDBClient client = new AmazonDynamoDBClient(credentials, REGION);

The credentials provider communicates with Amazon Cognito, retrieving both the unique identifier for authenticated and unauthenticated users as well as temporary, limited privilege AWS credentials for the AWS Mobile SDK. The retrieved credentials are valid for one hour, and the provider refreshes them when they expire.

Xamarin

Copy
// create a service client that uses credentials provided by Cognito var client = new AmazonDynamoDBClient(credentials, REGION)

The credentials provider communicates with Amazon Cognito, retrieving both the unique identifier for authenticated and unauthenticated users as well as temporary, limited privilege AWS credentials for the AWS Mobile SDK. The retrieved credentials are valid for one hour, and the provider refreshes them when they expire.