AWS Cognito强制刷新会话 [英] AWS Cognito force refresh session

查看:122
本文介绍了AWS Cognito强制刷新会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试刷新会话令牌(Access,Id,Refresh)时,我遇到了一些问题。我已经阅读了这个问题答案帮助我理解了一些正在发生的事情。但是我觉得我要做的并不是 getSession 是为了什么。

I'm running into some problems when I attempt to refresh my session tokens, (Access, Id, Refresh). I have already read this question and the answer has helped me understand what is going on some. But I feel what I am trying to do isn't quite what getSession is for.

我试图实现会话到期消息(完成),允许用户扩展其会话(刷新令牌)。从我收集的关于 getSession()的内容中,它返回旧标记(如果它们仍然有效)或新标记(如果它们无效)。如果我错了,请纠正我。

I am attempting to implement a session expiration message (done) that allows the user to extend their session (refreshes the tokens). From what I gather about getSession(), it returns either the old tokens, if they are still valid, or new tokens if they are not valid. Please correct me if I am wrong there.

我试图在每次点击扩展会话时给用户新的/刷新的令牌。出于开发目的,我有一个按钮,然后使用扩展会话按钮显示消息。我打电话给 getSession()时收到的代币是旧的代币,但我希望它们是新的代币。

I am attempting to give the user new/refreshed tokens every time they click on extend session. For dev purposes, I have a button which then displays the message with the extend session button. The tokens I receive when I call getSession() are the old ones, but I want them to be new ones.

所以基本上,取消旧会话并给他们一个新会议。

So basically, nullifying the old session and giving them a new one.

我的问题是:


  1. 我是否错过了对 getSession()的理解,如前所述?

  2. 我可以给用户吗?新的会话令牌(访问,身份验证,刷新)?

  3. 我可以在没有用户再次登录的情况下执行#2吗?

  1. Am I missing some understanding about getSession(), as previously mentioned?
  2. Can I give the user new session tokens (Access, Id, Refresh)?
  3. Can I do #2 without having the user sign in again?

谢谢。

编辑1:
可能有助于知道我没有使用任何联合身份。

EDIT 1: It may help to know that I am not using any Federated Identities.

推荐答案

您可以调用cognitoUser.refreshSession。我在这里找到了一个合理的例子:

You can call cognitoUser.refreshSession. I've found a reasonable example for you over here:

示例代码:如何使用Node.js和Express刷新Cognito用户池的会话

查找名为checkTokenExpiration的方法,它完全解释了什么你必须要刷新会话。

Look for the method called checkTokenExpiration, it explains perfectly well what you have to do to refresh the session.

这篇关于AWS Cognito强制刷新会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆