Amazon Cognito 需要一些解释
Amazon Cognito Need Something Explained
我正在查看 AWS Amplify 和 AWS Cognito 文档,我需要一些解释。取以下代码:
Auth.signIn({
username, // Required, the username
password, // Optional, the password
validationData, // Optional, a random key-value pair map which can contain any key and will be passed to your PreAuthentication Lambda trigger as-is. It can be used to implement additional validations around authentication
}).then(user => console.log(user))
.catch(err => console.log(err));
Here is some more code from the documentation:
Auth.signUp({
username,
password,
attributes: {
email, // optional
phone_number, // optional - E.164 number convention
// other custom attributes
},
validationData: [] //optional
})
.then(data => console.log(data))
.catch(err => console.log(err));
我的问题是,令牌存储在哪里?您将它们存储在状态中吗?如果是这样,当他们这样做时,他们是如何恢复精神的。还是 Auth 会处理这个问题,您可以在需要时调用 auth。如果是这样,你是否必须用 withAuthenticator 包装你的整个 ap?我不明白这一点。谢谢!
此外,如果您想要一个带有 AppSync 的安全端点,它是如何工作的?它会自动检查身份验证吗?您没有发送令牌,所以我不明白这是如何工作的。感谢您的帮助!
如果您使用 Amplify,它会将控件保留在 LocalStorage 中。这将由 Amplify 库管理。它还负责在第一个令牌过期时请求一个新令牌。再次声明:您无需担心,图书馆会为您处理。
问题是:您还必须使用 Amplify 将您的请求发送到 AppSync。当您使用 Amplify 时,库会看到您正在向 AWS 资源发出请求并且您已登录 Cognito,它会在发送请求之前将所需的 HTTP headers 附加到请求中。所有这些都将由 Amplify 库为您完成。你可以直接使用它..
我正在查看 AWS Amplify 和 AWS Cognito 文档,我需要一些解释。取以下代码:
Auth.signIn({
username, // Required, the username
password, // Optional, the password
validationData, // Optional, a random key-value pair map which can contain any key and will be passed to your PreAuthentication Lambda trigger as-is. It can be used to implement additional validations around authentication
}).then(user => console.log(user))
.catch(err => console.log(err));
Here is some more code from the documentation:
Auth.signUp({
username,
password,
attributes: {
email, // optional
phone_number, // optional - E.164 number convention
// other custom attributes
},
validationData: [] //optional
})
.then(data => console.log(data))
.catch(err => console.log(err));
我的问题是,令牌存储在哪里?您将它们存储在状态中吗?如果是这样,当他们这样做时,他们是如何恢复精神的。还是 Auth 会处理这个问题,您可以在需要时调用 auth。如果是这样,你是否必须用 withAuthenticator 包装你的整个 ap?我不明白这一点。谢谢!
此外,如果您想要一个带有 AppSync 的安全端点,它是如何工作的?它会自动检查身份验证吗?您没有发送令牌,所以我不明白这是如何工作的。感谢您的帮助!
如果您使用 Amplify,它会将控件保留在 LocalStorage 中。这将由 Amplify 库管理。它还负责在第一个令牌过期时请求一个新令牌。再次声明:您无需担心,图书馆会为您处理。
问题是:您还必须使用 Amplify 将您的请求发送到 AppSync。当您使用 Amplify 时,库会看到您正在向 AWS 资源发出请求并且您已登录 Cognito,它会在发送请求之前将所需的 HTTP headers 附加到请求中。所有这些都将由 Amplify 库为您完成。你可以直接使用它..