【问题标题】:AWS Cognito for Xamarin适用于 Xamarin 的 AWS Cognito
【发布时间】:2018-07-05 02:08:33
【问题描述】:

我正在尝试按照 this 指南使用 AWS Cognito 和 AWS 用户池创建新用户、更改密码等。我似乎找不到适用于 Android/iOS 的合适 Xamarin SDK。有没有存在的?

更具体地说,我在创建 Cognito 用户池对象时遇到问题。在我链接的示例中,他们有这个:

CognitoUserPool userPool = new CognitoUserPool(context, userPoolId, clientId, clientSecret);

// user pool can also be created with client app configuration:
CognitoUserPool userPool = new CognitoUserPool(context, userPoolId, clientId, clientSecret, clientConfiguration);

似乎没有CognitoUserPool 类。我在AWSSDK.CognitoIdentity 库中找不到任何类似或具有类似构造函数或任何东西的东西。是我遗漏了什么还是这还不被支持?

我也无法从此处显示的 Register a new user 示例代码中找到类似于 SignUpHandler 类的任何内容:

// create a handler for registration 
SignUpHandler handler = new SignUpHandler() {
    @Override
    public void onSuccess(CognitoUser user, boolean signUpConfirmation) {
        // The sign up was successful, "user" is a CognitoUser object of the user who was signed up.

        // "signUpConfirmation" will indicate if user is already confirmed.
    }

    @override
    public void onFailure(Exception exception) {
        // Sign up failed, code check the exception for cause and perform remedial actions.
    }
}

【问题讨论】:

    标签: android amazon-web-services xamarin amazon-cognito


    【解决方案1】:

    我只是在另一个帖子中answered 一个类似的问题。

    简而言之,目前 Xamarin/Unity SDK 不支持 Cognito 用户池客户端 SDK。 API 形状可用于直接与服务交互,但在 Android、iOS 和 JavaScript 以外的任何其他 SDK 中,您将找不到像 CognitoUserPoolCognitoUser 这样的助手。

    【讨论】:

    • 这很不幸。我希望他们计划尽快更新他们的 Xamarin SDK。
    • 还是这样吗?距离您发布此内容已经快 4 个月了。
    【解决方案2】:

    亚马逊通过 NuGet 提供了一个 C#/.NET SDK,它将是最新版本,并且应该提供您需要的功能。

    你可以在这里找到这个包:https://www.nuget.org/packages/AWSSDK.CognitoIdentity/

    您也可以通过 NuGet 控制台下载 NuGet:

    Install-Package AWSSDK.CognitoIdentity -Version 3.1.1.2
    

    最后可以通过Xamarin Studio中的NuGet Packages添加,通过搜索:

    AWSSDK.CognitoIdentity
    

    谢谢!

    【讨论】:

    • 是的,我看到了。但似乎缺少一些东西。在我链接的 Android 示例中,我没有看到类似于 CognitoUserPool 类的类。我也找不到任何适用于 Xamarin AWS 开发工具包的类似示例。我不确定他们是否在 Xamarin AWS 开发工具包中拥有它,因为它仍被认为是测试版。
    • 嘿!让我做一些测试并在内部询问团队。我会回复你的:)
    • 嘿!在这里与团队交谈,最新版本似乎是亚马逊提供的以下 NuGet:nuget.org/packages/AWSSDK.CognitoIdentity我将编辑我的答案以反映这个包
    • 非常感谢您的帮助。我仍然无法弄清楚如何创建 CognitoUserPool 对象或类似的东西。我知道 Cognito 用户池仍然很新,所以我想知道他们是否在 SDK 中实现了该功能。看起来他们没有。我将编辑我的答案以反映我在使用该 SDK 时遇到的具体问题。
    • 嘿,我会做更多的挖掘:)
    【解决方案3】:

    我知道这个问题/答案很旧,但我的搜索将我带到了这里,希望我可以帮助其他人。

    您现在可以通过安装 AWSSDK.Extensions.CognitoAuthentication Nuget 包来利用 AWS .Net SDK 中的用户池。

    Nuget:https://www.nuget.org/packages/AWSSDK.Extensions.CognitoAuthentication

    【讨论】:

      【解决方案4】:

      以下是将 AWS Cognito 与 Xamarin Forms 结合使用的示例:

      https://github.com/curtisshipley/CognitoForms

      【讨论】:

        猜你喜欢
        • 2022-10-01
        • 2017-12-11
        • 2020-01-26
        • 1970-01-01
        • 2019-05-03
        • 1970-01-01
        • 2018-05-19
        • 1970-01-01
        • 2020-01-01
        相关资源
        最近更新 更多