有没有办法检查这样的调用后是否超过了本地存储限制:
amplify.store("key", object);
Run Code Online (Sandbox Code Playgroud)
如果我尝试存储大于本地存储限制的内容会发生什么?
我正在尝试通过没有密码的链接实现身份验证。例如,用户输入他的电子邮件 -> cognito 发送一封带有用户可以单击并登录的链接的电子邮件。它
Cognito 通过自定义挑战支持它。例如https://aws-amplify.github.io/amplify-js/media/authentication_guide#using-a-custom-challenge
我已经创建了与我的认知池相关联的DefineAuthChallenge, CreateAuthChallenge, VerifyAuthChallengelambda 函数。CreateAuthChallenge生成发送到用户电子邮件和站点链接的代码。
接下来我计划从网站上的 url 中获取该代码并通过它像在文档中一样登录用户
Auth.signIn(username)
.then(user => {
if (user.challengeName === 'CUSTOM_CHALLENGE') {
Auth.sendCustomChallengeAnswer(user, challengeResponse)
.then(user => console.log(user))
.catch(err => console.log(err));
} else {
console.log(user);
}
})
.catch(err => console.log(err));
Run Code Online (Sandbox Code Playgroud)
但问题就在这里。 Auth.sendCustomChallengeAnswer需要从Auth.signIn. 但是,如果用户只是单击电子邮件中的链接,则根本不会有任何用户对象。并且放大 lib 不保存该中间会话用户对象,因此在页面重新加载时丢失了。它仅在身份验证完成后保存到其存储https://github.com/aws-amplify/amplify-js/blob/master/packages/amazon-cognito-identity-js/src/CognitoUser.js#L175
所以问题是如何Auth.signIn在页面重新加载时从函数中保存和重建用户对象。或者是否有更好的方法通过链接登录而无需密码?
authentication amazon-web-services amplifyjs amazon-cognito aws-amplify
我对此有点陌生。我有一个基于 React 的 Web 应用程序,我们一直在使用 AWS cognito 进行身份验证。我用来amazon-cognito-identity-js在用户池中注册用户并进行登录。
现在我正在尝试替换该库,aws amplify auth因为它的界面干净。但我不想经历设置过程(放大 init 和所有内容),我想像我使用的那样使用它amazon-cognito-identity-js。
这就是我到目前为止所做的
我已经Amplify Auth在我的app.js文件中配置了 -
import Amplify from 'aws-amplify';
Amplify.configure({
Auth: {
// REQUIRED only for Federated Authentication - Amazon Cognito Identity Pool ID
identityPoolId: 'my id pool',
// REQUIRED - Amazon Cognito Region
region: 'my-region',
// OPTIONAL - Amazon Cognito User Pool ID
userPoolId: 'my-userpool',
// OPTIONAL - Amazon Cognito Web Client ID (26-char alphanumeric string)
userPoolWebClientId: …Run Code Online (Sandbox Code Playgroud) 我有一个使用 React 的 AWS Amplify 应用程序。我希望TaskList只有在用户成功登录时才能加载(或重新加载)组件。但是,当页面加载时以及用户填写表单并注册时,组件从一开始就呈现出来重新加载。我一直在尝试多种解决方法,但我看不到如何使我的组件依赖于成功登录。我依靠默认的 Amplify 身份验证器功能来让用户登录 Cognito。
const App = () => (
<AmplifyAuthenticator>
<div>
My App
<AmplifySignOut />
<TaskList />
</div>
</AmplifyAuthenticator>
);
Run Code Online (Sandbox Code Playgroud) 在应用程序中,我尝试使用单独的按钮分别链接到 Amazon Cognito 用户池托管 UI 的注册和登录页面,但到目前为止我只能链接到登录页面。
我正在使用npm 中的AWS Amplify 包,我的代码可能如下所示:
import { Auth } from "aws-amplify";
//...
function openSignIn() {
Auth.federatedSignIn();
}
function openSignUp() {
// ???
}
Run Code Online (Sandbox Code Playgroud)
我没有找到任何federatedSignUp()可以接受相关选项的函数。
注册页面的 URL 为:
<domain>/signup?redirect_uri=<redirect_uri>&response_type=<response_typ>&client_id=<client_id>&identity_provider=<identity_provider>&scopes=<scopes>&state=<state>
Run Code Online (Sandbox Code Playgroud)
虽然我知道所有参数的值,但我不知道参数的值state,这使得很难在锚标记中立即使用它,即使我不喜欢这个解决方案。
有没有适当/优雅的解决方案?
javascript amazon-web-services amplifyjs amazon-cognito aws-amplify
x在一个反应应用程序中,我尝试使用 AWS Cognito 设置与 Google 的联合登录。当用户使用 Google 登录时,联合登录成功,并且我从 Auth.federatedSignIn() 收到一个令牌。但是,我的 Cognito 用户池中未创建新用户。
我可以看到一个新身份正在我的 Cognito 联合身份池中注册,但没有相应的用户添加到用户池中。我已检查我的 Amplify 配置中是否设置了正确的 userPoolId 和 userPoolWebClientId,并且我的身份提供商设置为“Google”。我还尝试将 federationTarget 设置为“Google”,但这并没有解决问题。
这是我的 Amplify 配置的简化版本:
Amplify.configure({
Auth: {
region: 'us-east-1',
userPoolId: ENV.COGNITO_USER_POOL_ID,
userPoolWebClientId: ENV.COGNITO_CLIENT_ID
},
aws_cognito_region: 'us-east-1',
aws_user_pools_id: ENV.COGNITO_USER_POOL_ID,
aws_user_pools_web_client_id: ENV.COGNITO_CLIENT_ID,
federationTarget: 'Google',
identityProvider: 'Google',
identityPoolId: 'us-east-1:xxxx-xxx-xxx-xxx-xxx',
oauth: {
domain: ENV.COGNITO_DOMAIN,
scope: ['email', 'openid', 'profile'],
redirectSignIn: `${window.location.origin}/login`,
redirectSignOut: `${window.location.origin}/login`,
responseType: 'code',
userPoolId: ENV.COGNITO_USER_POOL_ID,
userPoolWebClientId: ENV.COGNITO_CLIENT_ID,
identityProvider: 'Google',
userPoolGroupId: ENV.COGNITO_USER_POOL_ID,
federationTarget: 'Google'
}
});
Run Code Online (Sandbox Code Playgroud)
const cognitoResponse = await Auth.federatedSignIn(
'google',
{ …Run Code Online (Sandbox Code Playgroud) javascript amplifyjs amazon-cognito amazon-cognito-identity-js
我开始使用amplifijs并成功存储并检索存储中的对象,但我不知道如何删除它们的名称.
我用这个语法:
amplify.store("name",{valName1:"val1", ...});
var storage = amplify.store("name");
var val1 = storage.valName1;
Run Code Online (Sandbox Code Playgroud)
如何通过名称删除它们?
amplify.remove("name");
Run Code Online (Sandbox Code Playgroud) 好的,正在努力获得放大解码器.奇怪的问题.如果我有一个附加到我的请求的beforeSend,解码器不会触发.删除beforeSend并解码器触发.
以下是两个例子.
http://jsfiddle.net/sujesharukil/Td2P4/12/
http://jsfiddle.net/sujesharukil/Td2P4/14/
有人能告诉我发生了什么吗?如果我有一个beforeSend,为什么解码器不会工作?我假设解码器应该在收到请求后触发,所以beforeSend不应该对它产生任何影响!
注意:stackoverflow希望我在这里发布代码,而不仅仅是小提琴
//please check the fiddles
amplify.request({
resourceId: "testRequest",
data: {
json: JSON.stringify({
text: 'hello world'
})
},
success: function(data, status) {
console.log(data, status);
$('.messages').append('<div> text retrieved: ' + data.text + '</div>');
},
error: function(status, xhr) {
console.log(xhr);
}
});?
Run Code Online (Sandbox Code Playgroud)
救命?
-Suj
我尝试在 api doc(" https://aws-amplify.github.io/docs/cli-toolchain/graphql?sdk=js ")上使用示例架构,如下面的多对多连接
type Post @model {
id: ID!
title: String!
editors: [PostEditor] @connection(keyName: "byPost", fields: ["id"])
}
# Create a join model and disable queries as you don't need them
# and can query through Post.editors and User.posts
type PostEditor
@model(queries: null)
@key(name: "byPost", fields: ["postID", "editorID"])
@key(name: "byEditor", fields: ["editorID", "postID"]) {
id: ID!
postID: ID!
editorID: ID!
post: Post! @connection(fields: ["postID"])
editor: User! @connection(fields: ["editorID"])
}
type User @model {
id: ID!
username: String!
posts: …Run Code Online (Sandbox Code Playgroud) 我正在尝试查询特定日期范围内所有项目的项(其中具有AWS DateTime的CreatedAt和UpdatedAt字段)。例如,过去48小时。
例如,使用以下架构:
type Note @model @searchable @auth(rules: [{ allow: owner }]) {
id: ID!
note: String
createdAt: AWSDateTime
Run Code Online (Sandbox Code Playgroud)
我可以使用以下方式搜索日期:
query {
searchNotes(filter:{createdAt: { matchPhrasePrefix: "2018-12-27"}}) {
items{
id
title
createdAt
}
}
}
Run Code Online (Sandbox Code Playgroud)
它返回所有带有该字符串前缀的与UTC时间匹配的音符。
从那里,我必须使用moment.diff()或其他方法对自己进行排序。
我不确定是否有使用AppSync和GraphQl按日期和时间进行搜索/筛选的更好/更有效的方法?
谢谢。