AWS Cognito cookie storage



我正在尝试将 Cognito 设置为使用 cookie 而不是 localStorage 作为凭据,以便我可以让用户在域之间保持登录,例如 x.foo.com 和 y.foo.com。第一步是让它在本地主机上工作,但我卡住了。

文档显示一个简单的配置更改应该可以解决问题吗?

以下调试消息将提交到控制台:

[DEBUG] 37:08.223 AuthClass 
Object { idToken: {…}, refreshToken: {…}, accessToken: {…}, clockDrift: 0 }
ConsoleLogger.js:87
[DEBUG] 37:08.228 Credentials - No Cache module registered in Amplify ConsoleLogger.js:84
[DEBUG] 37:08.230 Credentials - set credentials from session ConsoleLogger.js:84
[DEBUG] 37:08.230 Credentials - No Cognito Federated Identity pool provided ConsoleLogger.js:84
[DEBUG] 37:08.230 AuthClass - cannot get cognito credentials No Cognito Federated Identity pool provided ConsoleLogger.js:94
[DEBUG] 37:08.231 AuthClass - Failed to get user from user pool ConsoleLogger.js:84
[ERROR] 37:08.232 AuthClass - Failed to get the signed in user No current user

似乎当您指定 cookieStorage 配置时,您需要手动应用缓存实例?我该怎么做,它会解决问题吗?

此配置有效:

{
region: 'eu-west-1',
userPoolId: 'eu-west-1_XXXXXX',
userPoolWebClientId: 'XXXXXX',
mandatorySignIn: false,
cookieStorage: {
domain: 'localhost',
secure: false,
path: '/',
expires: 365,
},
}

特别是,除非您使用的是https,否则对于localhost,secure必须是假的(Firefoxlocalhost忽略了这一点,但Chrome和Safari不会(。

相关内容

  • 没有找到相关文章

最新更新