如何强制客户端刷新认知令牌 [英] How can I force a cognito token refresh from the client
问题描述
我正在使用aws放大,我知道令牌会在需要时自动刷新,并且在后台完成.
I am using aws amplify and I know that the tokens get automatically refreshed when needed and that that is done behind the scenes.
我需要做的是通过Lambda后端进程在cognito用户池中的用户上更改自定义属性.我可以做到,并且正在运行.但是,Web客户端用户从未看到过这个新的自定义属性,我在想,他们看到该令牌的唯一方法是令牌是否被刷新,因为该值存储在JWT令牌中.
What I need to do is change a custom attribute on the user in the cognito user pool via a Lambda backend process. This I can do, and it is working. However, the web client user never sees this new custom attribute and I am thinking the only way they can see it is if the token gets refreshed since the value is stored within the JWT token.
推荐答案
未公开,但是您可以在用户上使用 refreshSession
方法.您对currentAuthenticatedUser和currentSession的下一次调用将更新配置文件属性(和组)
Undocumented, but you can use the refreshSession
method on the User. Your next call to currentAuthenticatedUser and currentSession will have updated profile attributes (and groups)
User = Auth.currentAuthenticatedUser()
Session = Auth.currentSession()
User.refreshSession(Session.refreshToken))
这篇关于如何强制客户端刷新认知令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!