Application expires after 1h even when regularly reporting my activity

被刻印的时光 ゝ 提交于 2019-12-11 10:12:22

问题


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.

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?

Thanks.


回答1:


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. 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
  4. Process Response

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.



来源:https://stackoverflow.com/questions/29962400/application-expires-after-1h-even-when-regularly-reporting-my-activity

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