AWS Cognito force refresh session

别来无恙 提交于 2020-01-02 08:49:12

问题


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.

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.

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.

My questions are:

  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?

Thank you.

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


回答1:


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

Sample code: how to refresh session of Cognito User Pools with Node.js and Express

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



来源:https://stackoverflow.com/questions/41556594/aws-cognito-force-refresh-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!