amazon-web-services - 联合 google 登录问题(aws amplify 和 Vue js)
问题描述
我用 vue js 和 aws amplify cognito 设置了 google auth。首次登录时,我收到此消息
Sign in failure ValidationException: 1 validation error detected: Value '{xxx.amazonaws.com/xxx}' at 'logins' failed to satisfy constraint: Map value must satisfy constraint: [Member must have length less than or equal to 50000, Member must have length greater than or equal to 1]
在第二次登录(按下按钮)时,它登录良好。
为什么不先登录,为什么会收到此消息?
配置:
const awsmobile = {
"aws_project_region": "ap-south-1",
"aws_cognito_identity_pool_id": "ap-south-1:25071751-c943-443a-94ab-62c6b0f1c496",
"aws_cognito_region": "ap-south-1",
"aws_user_pools_id": "ap-south-1_NAZCqoylw",
"aws_user_pools_web_client_id": "38a1itpo95f3tgln6vq43u3u4o",
"oauth": {
"domain": "mobileweb-dev.auth.ap-south-1.amazoncognito.com",
"scope": [
"phone",
"email",
"openid",
"profile",
"aws.cognito.signin.user.admin"
],
//"redirectSignIn": "https://test-kutumbh-app.netlify.app/home",
// "redirectSignOut": "https://test-kutumbh-app.netlify.app",
//"redirectSignIn": "https://dev-kutumbh-app.netlify.app/home",
//"redirectSignOut": "https://dev-kutumbh-app.netlify.app",
"redirectSignIn": "http://localhost:3000/home",
"redirectSignOut": "http://localhost:3000",
"responseType": "code"
},
"federationTarget": "COGNITO_USER_POOLS"
};
export default awsmobile;
enter code here
解决方案
默认情况下,Amplify 将在 Safari/Chrome 中打开 Cognito 托管 UI,但您可以通过提供自定义 URL 打开器来覆盖该行为。
解决使用 InAppBrowser 将给定 URL 转换为所需形式的问题,如Ashish-Nanda 评论在此问题中所建议的。
Amplify.configure({
...config, oauth: {
...config.oauth,
urlOpener: async function urlOpener(url, redirectUrl) {
await InAppBrowser.isAvailable();
const { type, url: newUrl } = await InAppBrowser.openAuth(url, redirectUrl, {
showTitle: false,
enableUrlBarHiding: true,
enableDefaultShare: false,
ephemeralWebSession: false,
});
const splitUrl = `myapp://?${newUrl.split("#_=_")[0].split("?")[1] || ''}`;
if (type === 'success') {
Linking.openURL(splitUrl);
}
}
}
})
推荐阅读
- python - C# 和 Python 中的 JPEG 压缩差异
- spring-boot - 将 Springfox 3.0.0 添加到 SpringBoot 后抛出“检测到不明确的搜索映射”
- smooch - 如何通过 node.js 检查用户 id 或对话 id 或用户 alreadt 是否存在于阳光中
- json - 带有 $ref 的 Json 模式属性
- c++ - 重新创建交换链与在调整大小时使用动态状态
- reactjs - 堆叠的动态输入 - reactjs
- python - Python BeautifulSoup 从 SPAN 和 A 标签中提取文本
- java - IntelliJ Maven 错误:存储库是非关联存储库,或未编入索引
- javascript - 使用 Angular 中另一个元素的 data-bs-target 定位 Bootstrap HTML 元素
- java - 如何从对话框片段内的按钮请求 onClick 事件中的权限