we are using Azure B2C Trust-framework policy for the JWT token, how do we manager the JWT Session and Refresh Token

Himabindeswara Rao Tammireddy 40 Reputation points
2024-05-13T05:59:32.2833333+00:00

Hi Team,

we are using Azure B2C Trust-framework policy for the JWT token, My question below: we want to keep JWT token expiry for 15 min, if user was active need to use the Re-refresh token to regenerate the token which ever user was active for 15 min how can we achive this.

Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,866 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Akhilesh 5,560 Reputation points Microsoft Vendor
    2024-05-16T09:09:04.11+00:00

    Hi @Himabindeswara Rao Tammireddy

    Thank you for post!

    To setup token expiration you have to specify it on token creation:

    new JwtSecurityToken(
                    ...
                    expires: DateTime.UtcNow.AddMinutes(90),
                    ....);
    

    Also, you can Configure lifetime of ID and Access Tokens and refresh token in your b2c tenant
    for more readings Configure token lifetime

    please refer the below posts which is similar to your ask
    https://learn.microsoft.com/en-us/answers/questions/845791/jwt-token-expiration-and-authorization
    https://learn.microsoft.com/en-us/answers/questions/1187991/jwtsecuritytoken-date-time-problem

    Hope this helps. Do let us know if you any further queries.

    Thanks,

    Akhilesh.


    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.