Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services AWS Cognito托管UI并使用授权代码OAuth流放大身份验证_Amazon Web Services_Vue.js_Amazon Cognito_Aws Amplify - Fatal编程技术网

Amazon web services AWS Cognito托管UI并使用授权代码OAuth流放大身份验证

Amazon web services AWS Cognito托管UI并使用授权代码OAuth流放大身份验证,amazon-web-services,vue.js,amazon-cognito,aws-amplify,Amazon Web Services,Vue.js,Amazon Cognito,Aws Amplify,我有一个Vue.js webapp,我正在尝试使用AWS Cognito和Amplify Auth添加简单的身份验证。我已经为OAuth流设置了启用“授权代码授予”的用户池。我还将重定向URL设置为https://example.auth.us-east-2.amazoncognito.com/login?response_type=code&client_id=XXXXXXXX&redirect_uri=https://example.com/auth/verify用于托管UI 这是托管UI重

我有一个Vue.js webapp,我正在尝试使用AWS Cognito和Amplify Auth添加简单的身份验证。我已经为OAuth流设置了启用“授权代码授予”的用户池。我还将重定向URL设置为
https://example.auth.us-east-2.amazoncognito.com/login?response_type=code&client_id=XXXXXXXX&redirect_uri=https://example.com/auth/verify
用于托管UI

这是托管UI重定向到的页面中的内容:

import { Auth } from "aws-amplify";

export default {
    async created() {
        try {
            await Auth.currentSession();
        } catch {
            console.error("Not authorized");
        }
    }
}
当我第一次通过托管用户界面登录并被重定向时,我收到一个错误,Amplify无法将我识别为正在进行身份验证。但是,如果我再次登录,控制台中不会出现错误,并且我有一个经过身份验证的会话


我知道授权码grant不会将令牌放在URL中,但即使在第一次登录时,我也会在localstorage中看到它们。我已经尝试切换到使用“令牌”OAuth流,但是Amplify文档说刷新令牌不是这样提供的,我不希望会话限制在1小时之内。这里有什么指导吗?

对于任何面临同样问题的人来说,这似乎是一个已知的问题

解决方法是订阅中心操作并在那里像

Hub.listen("auth", ({ payload: { event, data } }) => {
  switch (event) {
  case "signIn":
    // signin actions
    Auth.currentSession()
      .then(user => console.log(user)) // redirect to default page
      .error(err => console.log(err))
  case "signOut":
    // signout actions, redirect to '/' etc
  case "customOAuthState":
    // other changes
  }
}

请参阅

令人失望的是,只有一个解决办法,但它确实解决了我的问题。