Reputation: 243
I am trying to get started with the Cognito User authentication and login services. I am using a Xamarin PCL on Visual Studio 2015. I have a User Pool already created and all the necessary SDK's installed (.Core, .CognitoIdentity, .CognitoIdentityProvider, etc.).
However, when following the Getting Started guide, none of the Objects that are used in the guide exist in any of the libraries! I have been dealing with this for 2 weeks now and I have given up.
All I have are CognitoIdentityProviderExceptions/Configs/Client/Request/etc. as well as the AWSCredentials Objects. But, none of the CognitoUser Objects or Handlers exist so I cannot get anything started. What am I missing? I have downloaded all the SDKs and even the Xamarin Components but nothing is there.
If anyone knows what I am missing please let me know!
Upvotes: 0
Views: 1304
Reputation: 459
This feature has been added via C# CognitoAuthentication Extension Library
Quote from aws blog:
We are pleased to announce the Developer Preview of the CognitoAuthentication extension library. This library simplifies the authentication process of Amazon Cognito User Pools for .NET 4.5, .NET Core, and Xamarin developers.
Code sample:
using System;
using Amazon;
using Amazon.Runtime;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.CognitoIdentity;
using Amazon.CognitoIdentityProvider;
using Amazon.Extensions.CognitoAuthentication;
public async void GetS3BucketsAsync()
{
var provider = new AmazonCognitoIdentityProviderClient(new AnonymousAWSCredentials(),
FallbackRegionFactory.GetRegionEndpoint());
CognitoUserPool userPool = new CognitoUserPool("poolID", "clientID", provider);
CognitoUser user = new CognitoUser("username", "clientID", userPool, provider);
string password = "userPassword";
AuthFlowResponse context = await user.StartWithSrpAuthAsync(new InitiateSrpAuthRequest()
{
Password = password
}).ConfigureAwait(false);
CognitoAWSCredentials credentials =
user.GetCognitoAWSCredentials("identityPoolID", RegionEndpoint.<YourIdentityPoolRegion>);
using (var client = new AmazonS3Client(credentials))
{
ListBucketsResponse response =
await client.ListBucketsAsync(new ListBucketsRequest()).ConfigureAwait(false);
foreach (S3Bucket bucket in response.Buckets)
{
Console.WriteLine(bucket.BucketName);
}
}
}
Upvotes: 1
Reputation: 5661
The CognitoUser
object or Handlers
belong to the Cognito client side SDKs for Android, iOS and JavaScript only. Any other SDK is currently not supported for client side development and is only currently only powered with the low level shapes to interact directly with the APIs.
To know more about the platforms supported for client side development, you can read the sections for individual platforms in the developer guide.
Upvotes: 0