How do I keep a token alive more than 5 minutes?

The boiler-plate code for IOT Cloud for obtaining an authorization token gives a token which is valid for only 5 minutes. This means if I have an App which is connected to a Thing, and I come back 5 minutes later, the App does not know the token is invalid, and there is no error, but you can no longer communicate with the Thing.

The code for obtaining the token looks like this:

oauth_client = BackendApplicationClient(client_id=CLIENT_ID)
token_url = "https://api2.arduino.cc/iot/v1/clients/token"
oauth = OAuth2Session(client=oauth_client)

token = oauth.fetch_token(token_url=token_url,client_id=CLIENT_ID,
    client_secret=CLIENT_SECRET,include_client_id=True,audience="https://api2.arduino.cc/iot")
return token

How do I either increase the valid period for the token or refresh it?

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.