即使定期报告我的活动,申请也会在1小时后过期 [英] Application expires after 1h even when regularly reporting my activity

查看:104
本文介绍了即使定期报告我的活动,申请也会在1小时后过期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前,我有一个问题,我的UCWA应用程序在一段时间后过期.作为解决此问题的方法,我发现我应该不时提出一个请求,以使其保持生命力.我决定设置一个间隔,每3分钟请求一次reportMyActivity资源.

Previously I had a problem that my UCWA application expired after some time. As a solution to this problem, I have found out that I should make a request every now and then to keep it alive. I decided to set an interval and every 3 minutes request reportMyActivity resource.

但是,无论如何,我的应用程序总是在1小时后过期.有什么解决办法吗?另外,建议使用什么方法在不使用示例库离开网站的情况下重新创建应用程序?

However, no matter what, my application always expires after 1 hour. Is there any solution to this? Alternatively, what is the recommended way of re-creating application without leaving website using sample libraries?

谢谢.

推荐答案

令牌过期的时间并不完全相关,重要的是401 Unauthorized指示令牌已过期.在该失败的请求中,应该有一个(或两个)WWW-Authenticate标头,这些标头可用于指向获取下一个令牌的位置.您可以考虑更改负责向UCWA发送请求的逻辑,以反映如下内容:

The time at which the token expires is not entirely relevant, what is important is the 401 Unauthorized indicating that the token has expired. In that failed request there should be one (or two) WWW-Authenticate headers which can be used to point at where to get the next token. You may consider altering the logic responsible for sending requests to UCWA to reflect something like the following:

  1. 发送请求
  2. 检查响应状态代码
  3. 如果401 ...
    • 检查WWW-Authenticate标头并重新发出身份验证请求
    • 存储令牌并返回到步骤1
  1. Send Request
  2. Check Response status code
  3. If 401...
    • Check WWW-Authenticate header and re-issue authentication request(s)
    • Store token and proceed back to step #1

这样,应用程序无需跟踪令牌的到期时间,并且一旦遇到401,就可以懒惰地检索新令牌.

This way the application would not need to keep track of the expiry time of the token and could lazily retrieve a new one once it encounters the 401.

这篇关于即使定期报告我的活动,申请也会在1小时后过期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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