Search code examples
azureazure-active-directoryazure-ad-b2caccess-token

How do I increase token lifetime for daemon app on Azure AD B2C


How do I increase token lifetime for daemon app on Azure B2C? I have problem finding correct setting on Azure Portal.

I am setting up Azure B2C security. Everything is fine, I have daemon app which acquires token, saves it to cache, and calls API which check tokens validity. Subsequent calls check token lifetime and if expired, silently gets new one.

I have a requirement that token lifetime has to be more than default 1 hour.

I have found how to increase token life time for user-flow under Azure AD B2C | User flows / policy/properties.

But daemon apps don't use user flows. Is there another place to configure this? Is it somewhere in manifest and have I missed it? Do I not understand deamon apps and client credentials flow correctly?

I am using recommended libraries described here https://github.com/AzureAD/microsoft-identity-web/wiki .


Solution

  • As you said, the lifetime of an access token is 1 hour by default. If you want to customize the lifetime of the token (increase or decrease), you need to use powershell to create a token lifetime policy, and then assign the policy to the service principal to set the token lifetime.

    However, as far as I know, B2C currently does not support daemon-based client credential flow.