You can use Refresh tokens, Refresh tokens have a longer lifetime than access tokens. The default lifetime for the refresh tokens is 24 hours for single page apps and 90 days for all other scenarios. Please see the doc for more details - https://learn.microsoft.com/en-us/azure/active-directory/develop/refresh-tokens#refresh-token-lifetime
Token prolongation
via UI
https://developer.microsoft.com/en-us/graph/graph-explorer
it is possible to obtain token
how to make it 12h valid ?
Microsoft Graph
3 answers
Sort by: Most helpful
-
Vicky Kumar (Mindtree Consulting PVT LTD) 1,161 Reputation points Microsoft Employee
2022-12-21T17:10:23.47+00:00 -
Zehui Yao_MSFT 5,876 Reputation points
2022-12-26T10:25:16.823+00:00 Hi @Cherkashyn Vitalii, EF-320 If you want to customize the lifetime of the access token, you can use powershell to create a token lifetime policy, and then assign the policy to the service principal to set the token lifetime. Best Wishes.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread. -
Cherkashyn Vitalii, EF-320 1 Reputation point
2023-01-06T11:03:39.63+00:00 @Zehui Yao_MSFT may I ask you about shell/curl commands how to obtain this "long-term token" when I have "usual token" ?
I'm working mostly on Linux, but I'm sure Microsoft also has similar solution.For instance Keycloak (authentication solution): for obtaining prolongation token need to send POST request like
json curl -X POST -d '{ "tokenLifespanInSeconds": '${TTL_SEC}'} ...
@Vicky Kumar (Mindtree Consulting PVT LTD) thanks for the link