Session timeout using access token refresh
Methods, systems, and devices for data management are described. A client may transmit, to a server, a login request for an application. The login request may include authentication parameters associated with a user. The client may receive, from the server, an access token that supports access via a user interface to one or more services associated with the application before expiration of a time-to-live for the access token. The client may transmit, prior to expiration of the time-to-live for the access token and based on a session inactivity timeout timer being active, a refresh request for a new access token. The refresh request may include an indication of the access token. The application may receive the new access token in response to the refresh request, and the new access token supports access to the one or more services before expiration of a time-to-live for the new access token.
1 . A method, comprising:
transmitting, to a server, a login request for an application, the login request comprising one or more authentication parameters associated with a user;
receiving, from the server in response to the login request, an access token that supports access via a user interface to one or more services associated with the application before expiration of a time-to-live for the access token;
initializing, by the application in response to receiving the access token, a session inactivity timeout timer with a same duration as the time-to-live for the access token, wherein the application is configured to restart the session inactivity timeout timer in response to detection of an action by the user at the application;
transmitting, based at least in part on the time-to-live for the access token reaching a threshold time-to-live while the session inactivity timeout timer is active, a refresh request for a new access token, the refresh request including an indication of the access token; and
receiving the new access token in response to the refresh request, wherein the new access token supports access to the one or more services before expiration of a respective time-to-live for the new access token.
2 . The method of claim 1 , further comprising:
detecting the action by a peripheral device in association with the user interface of the application; and
restarting the session inactivity timeout timer in response to detecting the action.
3 . The method of claim 1 , further comprising:
detecting expiration of the session inactivity timeout timer; and
transmitting, to the server, a logout request that is configured to invalidate the new access token.
4 . The method of claim 1 , further comprising:
detecting access to the user interface while the user interface is in an inactive state, wherein the session inactivity timeout timer is restarted in response to detecting the access;
transmitting, to the server after the session inactivity timeout timer is restarted and based at least in part on the session inactivity timeout timer being active, a data request that includes the new access token; and
receiving, in response to the data request, an indication of denial of the data request based at least in part on expiration of the time-to-live of the new access token.
5 . The method of claim 4 , wherein the user interface is in the inactive state when the access is detected based at least in part on the application being closed, a tab displaying the user interface being closed, or any combination thereof.
6 . The method of claim 1 , further comprising:
detecting access to the user interface while the user interface is in an inactive state, wherein the session inactivity timeout timer is restarted in response to detecting the access;
transmitting, to the server after the session inactivity timeout timer is restarted and based at least in part on the session inactivity timeout timer being active, a data request that includes the new access token; and
receiving, in response to the data request, requested data, wherein the requested data is received based at least in part on the data request being transmitted before expiration of the time-to-live of the new access token.
7 . The method of claim 1 , wherein:
the server is associated with a data management service that is configured to manage backup of one or more data sources associated with the data management service; and
the time-to-live of the access token is associated with a service level agreement for the data management service.
8 . The method of claim 1 , further comprising:
transmitting an additional refresh request for a subsequent access token; and
receiving, in response to the additional refresh request, an indication of denial of the additional refresh request based at least in part on a duration of a session period exceeding a maximum duration threshold.
9 . An apparatus, comprising:
one or more processors;
memory coupled with the one or more processors; and
instructions stored in the memory and executable by the one or more processors to cause the apparatus to:
transmit, to a server, a login request for an application, the login request comprising one or more authentication parameters associated with a user;
receive, from the server in response to the login request, an access token that supports access via a user interface to one or more services associated with the application before expiration of a time-to-live for the access token;
initialize, by the application in response to receiving the access token, a session inactivity timeout timer with a same duration as the time-to-live for the access token, wherein the application is configured to restart the session inactivity timeout timer in response to detection of an action by the user at the application;
transmit, based at least in part on the time-to-live for the access token reaching a threshold time-to-live while the session inactivity timeout timer is active, a refresh request for a new access token, the refresh request including an indication of the access token; and
receive the new access token in response to the refresh request, wherein the new access token supports access to the one or more services before expiration of respective a time-to-live for the new access token.
10 . The apparatus of claim 9 , wherein the instructions are further executable by the one or more processors to cause the apparatus to:
detect the action by a peripheral device in association with the user interface of the application; and
restart the session inactivity timeout timer in response to detecting the action.
11 . The apparatus of claim 9 , wherein the instructions are further executable by the one or more processors to cause the apparatus to:
detect expiration of the session inactivity timeout timer; and
transmit, to the server, a logout request that is configured to invalidate the new access token.
12 . A non-transitory computer-readable medium storing code, the code comprising instructions executable by one or more processors to:
transmit, to a server, a login request for an application, the login request comprising one or more authentication parameters associated with a user;
receive, from the server in response to the login request, an access token that supports access via a user interface to one or more services associated with the application before expiration of a time-to-live for the access token;
initialize, by the application in response to receiving the access token, a session inactivity timeout timer with a same duration as the time-to-live for the access token, wherein the application is configured to restart the session inactivity timeout timer in response to detection of an action by the user at the application;
transmit, based at least in part on the time-to-live for the access token reaching a threshold time-to-live while the session inactivity timeout timer is active, a refresh request for a new access token, the refresh request including an indication of the access token; and
receive the new access token in response to the refresh request, wherein the new access token supports access to the one or more services before expiration of a respective time-to-live for the new access token.
13 . The non-transitory computer-readable medium of claim 12 , wherein the instructions are further executable by the one or more processors to:
detect the action by a peripheral device in association with the user interface of the application; and
restart the session inactivity timeout timer in response to detecting the action.
14 . The non-transitory computer-readable medium of claim 12 , wherein the instructions are further executable by the one or more processors to:
detect expiration of the session inactivity timeout timer; and
transmit, to the server, a logout request that is configured to invalidate the new access token.