Extending the expiration time for a token


I am working on an Atlassian Connect app, but I noticed that after some minutes the session expires and I get the following error on the page:
Unauthorized: Authentication request has expired. Try reloading the page.

Looking in the documentation I found out the Token has an expiration of 15 minutes, see the Token expiration section from the following page:


It mentions that: “Rather than handling a token expiration error, track the expiration time and request a new token before it expires”

How can I request a new token?

On the following page:

On the Token validity period section, it is mentioned the use of the AP.context.getToken() function to refresh tokens. However, my module is of the “Search Request View” type and this type of modules doesn’t work with the Connect Javascript API(known as AP). AP only works in a Connect iFrame, but this module is not in such a context.

Then, How can I request a new token? in a “Search Request View” module type?