gpt4 book ai didi

aws-amplify - AWS Amplify Analytics 是否可以在没有 Cognito 用户池的情况下使用?

转载 作者:行者123 更新时间:2023-12-05 01:12:46 27 4
gpt4 key购买 nike

我正在尝试通过 Amplify SDK 将 Pinpoint Analytics 实现到现有的 React Native 应用程序中。我们拥有自己的 authN 和 authZ 实现的现有用户群,因此我们不需要(更重要的是,负担不起)Cognito 用户池。

一方面,当 recording events 时,Pinpoint API 不需要与 Cognito 进行任何集成。 , 然而 amplify documentation似乎在使用 analytics 时需要 auth 插件,而在配置 Amplify 时需要 auth 参数。

Amplify.configure({
// To get the AWS Credentials, you need to configure
// the Auth module with your Cognito Federated Identity Pool
Auth: {
identityPoolId: 'us-east-1:xxx-xxx-xxx-xxx-xxx',
region: 'us-east-1'
},
Analytics: {
// OPTIONAL - disable Analytics if true
disabled: false,
...

有没有一种方法可以通过 Amplify 使用 analytics 而无需生成用户池?我已经尝试检查 AWS 移动 SDK,但它们显然已被弃用,大多数文档现在都指向 Amplify。我们可以直接使用 Pinpoint API,但该实现似乎有点多余。

最佳答案

免责声明:我不在 AWS Amplify/Cognito/Pinpoint 产品团队工作。

根据我的研究,AWS Amplify Analytics(Amazon Pinpoint) 可以在没有 Cognito 用户池的情况下使用,但需要 Cognito Identity Pool 进行授权。

Cognito 用户池和 Cognito 身份池的概念有时会令人困惑,但简单来说,我将它们区分如下:

Amazon Cognito User Pools is a full-featured user directory service to handle user registration, storage, authentication, and account recovery.

Amazon Cognito Identity Pools (Federated Identities) is a way to authorize use of AWS services in your app.

当您将您的应用程序与 Amazon Pinpoint 集成时,这些应用程序需要访问 AWS 服务的权限。因此,Amazon Cognito 身份池提供了一种授权在您的应用程序中使用 AWS 服务的方法。使用 Cognito 身份池,您可以获得临时具有您通过 IAM 策略定义的访问 AWS 服务的权限的 AWS 凭证。IAM 策略(auth_role 和 unauth_role)应包含允许您将数据发送到服务的 Pinpoint 相关策略。请参见下面的示例:

{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobiletargeting:UpdateEndpoint",
"mobiletargeting:PutEvents"
],
"Resource": [
"arn:aws:mobiletargeting:*:${accountID}:apps/${appId}*"
]
}
]
}

总结:

使用 Amazon Cognito Identity Pool 提供了一种更安全可靠的方式来访问应用程序中的 AWS 后端资源,而不是将凭证(即访问 key 和 secret key )嵌入到您的应用程序中。

希望这对您有所帮助!

关于aws-amplify - AWS Amplify Analytics 是否可以在没有 Cognito 用户池的情况下使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61520354/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com