Tag: Windows Phone

Caching Amazon Cognito Identity IDs

by Norm Johanson | on | in .NET | Permalink | Comments |  Share

Amazon Cognito is a service that you can use to get AWS credentials to your mobile and desktop applications without embedding them in your code. A few months ago, we added a credentials provider for Cognito. In version 2.3.14 of the AWS SDK for .NET, we updated the credentials provider to support caching the identity ID that Cognito creates.

Caching IDs is really useful for mobile and desktop applications where you don’t want to require users to authenticate but need to remember the user for each run of the application. For example, if you have a game whose scores you want to store in Amazon S3, you can use the identity ID as the object key in S3. Then, in future runs of the game, you can use the identity ID to get the scores back from S3. To get the current identity ID, call the GetIdentityId method on the credentials provider. You can also use the identity ID in the AWS Identity and Access Management (IAM) role that Cognito is using to restrict access to only the current user’s score. Below is a policy that shows how to use the Cognito identity ID. In the policy, the variable ${cognito-identity.amazonaws.com:sub} is used. When the policy is evaluated, ${cognito-identity.amazonaws.com:sub} is replaced with the current user’s identity ID.

    "Version" : "2012-10-17",
    "Statement" : [
            "Sid" : "1",
            "Effect" : "Allow",
            "Action" : [
            "Resource" : "*"
            "Sid" : "2",
            "Effect" : "Allow",
            "Action" : ["s3:PutObject", "s3:GetObject"]
            "Resource" : "arn:aws:s3:::my-game-scores-bucket/scores/${cognito-identity.amazonaws.com:sub}.json"

In the Windows Phone and Windows Store version of the SDK, caching is controlled by the IdentityIdCacheMode property on Amazon.CognitoIdentity.CognitoAWSCredentials. By default, this property is set to LocalSettings, which means the identity ID will be cached local to just the device. Windows.Storage.ApplicationData.Current.LocalSettings is used to cache the identity ID. It can also be set to RoamingSettings, which means the identity ID will be stored in Windows.Storage.ApplicationData.Current.RoamingSettings, and the Windows Runtime will sync data stored in this collection to other devices where the user is logged in. To turn off caching, set IdentityIdCacheMode to None.

To enable caching for the .NET 3.5 and 4.5 versions of the SDK, you need to extend the Amazon.CognitoIdentity.CognitoAWSCredentials class and implement the GetCachedIdentityId, CacheIdentityId, and ClearIdentityCache methods.

Supporting Windows Phone 8.1

by Norm Johanson | on | in .NET | Permalink | Comments |  Share

When we introduced version 2 of AWS SDK for .NET, it included support for Windows Store 8 and Windows Phone 8. With the release of Windows Phone 8.1, the runtime environment has changed to make it similar to Windows Store apps and to support Universal Apps. This means that when you create a new Windows Phone 8.1 project, you have two options, the older Silverlight runtime and the newer Universal runtime. Our current Windows Phone 8 version of the SDK works with the older Microsoft Silverlight runtime but is incompatible with the new Universal runtime.

To address the incompatibility with Universal Apps, we have created a new version of the SDK in version This new version is a portable class library that targets both the Windows Store 8.1 and Windows Phone 8.1 platforms. It is included in the NuGet package for the SDK as well as in the installer. The supported services in the new version of the SDK.

  • Amazon Cognito
  • Amazon CloudWatch
  • Amazon DynamoDB
  • Amazon EC2
  • Amazon Elastic Transcoder
  • Amazon Glacier
  • Amazon Kinesis
  • Amazon RDS
  • Amazon S3
  • Amazon SimpleDB
  • Amazon SES
  • Amazon SNS
  • Amazon SQS
  • Auto Scaling
  • AWS CloudFormation
  • AWS Elastic Beanstalk
  • AWS Identity and Access Management
  • AWS Security Token Service
  • Elastic Load Balancing

Give it a try and let us know what you think.