I am using the endpoint /oauth2/token to request (via a HTTP POST) an authentication bearer token from Azure Active Directory. Everything is setup fine within AAD to register the web client which retrieves this token using this flow. A client_id and client_secret (shared symmetric key) is used and I successfully get the json response containing the jwt bearer token for auth.
What I am trying to understand is to know how we can configure the expiry of the token beyond the 1 hour expiry which seems to be on the token I acquire via this POST request. The shared key which I generated in the Azure AD classic portal has a 2yr expiry. However, the token returned has 1hr expiry.
Based on this, I am assuming that the way this flow works (at least as far as AAD is concerned) is that the our web client needs to schedule itself to re-post a request for a new auth token within the 1hr timeframe to ensure the freshness of the auth token used for authenticated REST calls made by the web client. I guess it could also trap an exception if the previously issued token fails and then make a new request (that's just implementation details...).
Is this the normal way of keeping an auth token refreshed for this flow ? I know that with most of the other flows, a refresh token is generated and the OAuth "dance" can be done to keep the auth token valid. ADAL abstracts all those details nicely but in this case I am using the client credential flow and using a HTTP POST request to the oauth2/token endpoint and within this flow (in accordance with the OAuth2 RFC) no refresh token is provided. ]
I had assumed that maybe it was possible to configure a longer expiry on the OAuth token, maybe even an indefinite token for this server/to-server confidential client scenario. Is this possible within the Azure AD settings ?
The document linked at Azure AD token lifetime config suggests that the lifetimes are configurable.