[英]React and Redux with the new auth0 SPA storing token
I'm using the new auth0-SPA to make api calls.我正在使用新的 auth0-SPA 进行 api 调用。 I'm facing an issue when storing the token in redux as I am making API calls with my actions.我在 redux 中存储令牌时遇到问题,因为我正在使用我的操作进行 API 调用。 I'm concerned about the refresh of my token where in the docs it says to use the我担心我的令牌的刷新,在文档中它说要使用
await getTokenSilently()
however I am doing this on the inital load of the context and storing that token in state, how will I know when to update the token as I can only store serialised data within state.但是我在上下文的初始加载中执行此操作并将该令牌存储在 state 中,我怎么知道何时更新令牌,因为我只能在 state 中存储序列化数据。 Unlike in the docs where they are using that method directly on a fetch.与他们在获取时直接使用该方法的文档不同。 Thanks!谢谢!
You can also store your token in cookie.您还可以将令牌存储在 cookie 中。 Your apiclient will include cookie in every API call.您的 apiclient 将在每个 API 调用中包含 cookie。 That also helps in dealing with browser refresh because redux will loose the token in browser refresh.这也有助于处理浏览器刷新,因为 redux 将在浏览器刷新时丢失令牌。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.