Amazon CognitoUserPool和其他对象不存在 [英] Amazon CognitoUserPool and other Objects do not exist

查看:307
本文介绍了Amazon CognitoUserPool和其他对象不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Cognito用户身份验证和登录服务.我在Visual Studio 2015上使用Xamarin PCL.我已经创建了一个用户池,并安装了所有必需的SDK(.Core,.CognitoIdentity,.CognitoIdentityProvider等).

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.

我所拥有的都是CognitoIdentityProviderExceptions/Configs/Client/Request/etc.以及AWSCredentials对象.但是,不存在任何CognitoUser对象或处理程序,所以我什么也无法开始.我想念什么?我已经下载了所有SDK,甚至Xamarin组件,但都没有.

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!

推荐答案

此功能已通过C#CognitoAuthentication扩展库

This feature has been added via C# CognitoAuthentication Extension Library

aws博客的语录:

我们很高兴地宣布 CognitoAuthentication扩展库.该库简化了 .NET 4.5,.NET的Amazon Cognito用户池的身份验证过程 Core和Xamarin开发人员.

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.

代码示例:

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);
        }
    }
}

  • 博客
  • NuGet
    • blog
    • NuGet
    • 这篇关于Amazon CognitoUserPool和其他对象不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆