About changing lifetime of refresh token - Microsoft Q&A (2024)

Share via

About changing lifetime of refresh token - Microsoft Q&A (1)

Phu Le 40Reputation points

2023-02-27T11:12:38.6866667+00:00

Dear Microsoft Advertising API team,

I read the below article

You can't configure the lifetime of a refresh token. You can't reduce or lengthen their lifetime. Configure sign-in frequency in Conditional Access to define the time periods before a user is required to sign in again.https://learn.microsoft.com/EN-US/azure/active-directory/develop/refresh-tokens#token-timeouts

and executed following steps

  1. Go to my registered application
  2. Security > Conditional Access, create a policy
  3. In create new policy screen, section 「Session」, tick checkbox 「Sign-in frequency」and set-up Periodic reauthentication (1 hour)
  4. Authenticate my application througth Microsoft ads account to get refresh token
  5. Waiting for more than 1 hour with in-active refresh token About changing lifetime of refresh token - Microsoft Q&A (2)
  6. Use refresh token to create access token

Expected: get error that refresh token is expired

Actual: call request successfully→refresh token is still active

May I lack of any configuration ?

Thanks & Best regards

Phu

Microsoft Entra ID

Microsoft Entra ID

A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.

21,367 questions

Sign in to follow

0 commentsNo comments

0{count} votes

    Sign in to comment

    Accepted answer

    1. About changing lifetime of refresh token - Microsoft Q&A (3)

      Akshay-MSFT 17,771Reputation points Microsoft Employee

      2023-03-01T11:24:04.81+00:00

      @Phu Le

      Thank you for your response. As per your policy screenshot you have opted for Sign in frequency- periodic reauthentication- after every on-hour, which means the user session will be revoked after an hour.

      About changing lifetime of refresh token - Microsoft Q&A (4)

      As per Refresh and session token lifetime policy properties

      After the retirement of refresh and session token configuration on January 30, 2021, Azure AD will only honor the default values described below. If you decide not to use Conditional Access to manage sign-in frequency, your refresh and session tokens will be set to the default configuration on that date and you'll no longer be able to change their lifetimes.

      Refresh Token max inactive time is 90 days, if the user session continues it would renew without impacting the session but not when session controls are applied.

      About changing lifetime of refresh token - Microsoft Q&A (5)

      Please do let me know if you have any further queries in the comments section.

      Thanks,

      Akshay Kaushik

      Please "Accept the answer" (Yes/No), and share your feedback if the suggestion works as per your business need. This will help us and others in the community as well.

      1. About changing lifetime of refresh token - Microsoft Q&A (6)

        Phu Le 40Reputation points

        2023-03-01T18:48:17.46+00:00

        @Akshay-MSFT

        Thank you for your response

        Let me summarize my situation

        I create my own application in Azure Active Directory > App registrations

        Then I created a conditional access policy about Sign-in frequency (Periodic reauthentication 1 hour) applied to my application

        After that I used OAuth 2.0 authorization code flow to get the initial access and refresh token

        With above policy setting, I imagine that my refresh token will be invalidated after 1 hour but it was still validated.

        Please help to confirm that my understanding about that policy is wrong or I did config some thing lack

        Thanks & Best regards

        Phu

      2. About changing lifetime of refresh token - Microsoft Q&A (7)

        Phu Le 40Reputation points

        2023-03-02T05:57:44.0233333+00:00

        Dear @Akshay-MSFT

        Thank you for your response.

        Firstly, I registered my own application from Azure Active Directory > App registrations. After that I created new conditional access policy by setting Session- Sign-in frequency Periodic reauthentication 1 hour

        Then use OAuth 2.0 authorization code flow to get pair of refresh token and access token to access data of my customer

        With above policy setting, I understand that my refresh token will be invalidated after 1 hour. Is it right?

        But actual my refresh token still validated. May I understand wrong about Sign-in frequency policy or lack of any config.

        Thanks & Best Regards,

        Phu

      3. About changing lifetime of refresh token - Microsoft Q&A (8)

        Akshay-MSFT 17,771Reputation points Microsoft Employee

        2023-03-03T05:50:59.95+00:00

        @Phu Le ,

        This is because the token you have requested token via AuthCodeGrant via lets say a service principal and it is valid for default time, but the application you would be using has a session token (cookies) of 1 hour (in control of IDP). Expiring either of refresh or session token will ask the user to reauthenticate.

        As per https://learn.microsoft.com/en-us/azure/active-directory/enterprise-users/users-revoke-access#session-tokens-cookies :

        • When a user opens a browser and authenticates to an application via Azure AD, the user receives two session tokens. One from Azure AD and another from the application.
        • The authorization policies of Azure AD are reevaluated as often as the application sends the user back to Azure AD. Reevaluation usually happens silently, though the frequency depends on how the application is configured. It's possible that the app may never send the user back to Azure AD as long as the session token is valid.

        Thanks,

        Akshay Kaushik

        Please do let me know if you have any further queries.

      Sign in to comment

    1 additional answer

    Sort by: Most helpful

    Most helpful Newest Oldest

    1. About changing lifetime of refresh token - Microsoft Q&A (9)

      Andy David - MVP 147.6KReputation points MVP

      2023-02-27T12:04:52.4066667+00:00

      Hi, not every app honors the policy. so that could be your issue

      https://learn.microsoft.com/en-us/azure/active-directory/conditional-access/concept-conditional-access-session#sign-in-frequency

      About changing lifetime of refresh token - Microsoft Q&A (10)

      1. About changing lifetime of refresh token - Microsoft Q&A (11)

        Phu Le 40Reputation points

        2023-02-28T12:39:36.3+00:00

        Dear @Andy David - MVP

        Thank you for your reply quickly.

        I have registered own application as below guide link

        https://learn.microsoft.com/en-us/advertising/guides/authentication-oauth-register?view=bingads-13

        You mean that own applications is not honor to 「Sign-in frequency」policy

        How does my own application config or register charged service to honor this policy?

        Incase cannot use 「Sign-in frequency」policy, the default lifetime of refresh token is 90 days as described in below link

        https://learn.microsoft.com/en-us/azure/active-directory/develop/active-directory-configurable-token-lifetimes#refresh-and-session-token-lifetime-policy-properties

        Please help me to confirm which ones is correct

        1. refresh token will be expired after 90 days
        2. refresh token will be expired after consecutive 90 days in in-active state ( mean that if use refresh token everyday, it will not be expired)

        Thanks & Best regards

        Phu

      Sign in to comment

    Sign in to answer

    Your answer

    About changing lifetime of refresh token - Microsoft Q&A (2024)

    FAQs

    About changing lifetime of refresh token - Microsoft Q&A? ›

    Hi, the lifetime of a refresh token cannot be changed. The lifetime of a refresh token is set to 90 days by default and cannot be reduced or lengthened. However, you can configure the sign-in frequency in Conditional Access to define the time periods before a user is required to sign in again.

    What is the recommended lifetime of refresh token? ›

    Token lifetime

    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. Refresh tokens replace themselves with a fresh token upon every use.

    What is the sliding lifetime of refresh token? ›

    Sliding: when refreshing the token, the lifetime of the refresh token will be renewed (by the amount specified in SlidingRefreshTokenLifetime). The lifetime will not exceed the absolute lifetime.

    What is the best practice for refresh token expiration? ›

    Best practice

    Set the expiration time for refresh tokens in such a way that it is valid for a little longer period than the access tokens. For example, if you set 30 minutes for access token then set (at least) 24 hours for the refresh token.

    Can a refresh token never expire? ›

    When enabled, a refresh token will expire based on an absolute lifetime, after which the token can no longer be used. If rotation is enabled, an expiration lifetime must be set. The Absolute Expiration of the rotating refresh token is defined on creation and is not changed, even with an exchange.

    How do I check my refresh token lifetime? ›

    Unfortunately, there is no option to find the expiration time for the refresh token, because it is depending on authorization server and the type of client application, and it is not communicated to the client. In the Microsoft identity platform, the default lifetime for refresh tokens is 90 days.

    Should refresh tokens be one time use? ›

    Refresh tokens are designed to be long-lived but must be revoked at need. Access tokens are designed to be short-lived, because they can't be revoked (in most cases).

    Should refresh token be renewed? ›

    This means that every time a refresh token is used to obtain a new access token, a new refresh token is also issued and the old one is invalidated. Limited validity: Although refresh tokens are valid for longer than access tokens, they should still have a maximum lifespan and be renewed or checked regularly.

    What happens after refresh token expires? ›

    The member must reauthorize your application when refresh tokens expire. When you use a refresh token to generate a new access token, the lifespan or Time To Live (TTL) of the refresh token remains the same as specified in the initial OAuth flow (365 days), and the new access token has a new TTL of 60 days.

    What is the refresh token policy? ›

    Refresh tokens are required only when a user's session has expired or isn't available. For example, you set a refresh token policy to expire the token after 1 hour. If a user uses the app for 2 hours, the user isn't forced to reauthenticate after 1 hour.

    Is refresh token a good practice? ›

    Short-lived access tokens, long-lived refresh tokens, and blacklists are a great approach for most services. Whether to use these over a session approach depends on how sensitive your data is and how much damage can be done in a short amount of time.

    What is refresh token rotation strategy? ›

    Refresh token rotation is a security mechanism designed to minimize the risks associated with token theft and unauthorized use. In this process, each time a refresh token is used to acquire a new access token, a brand new refresh token is also generated and the previous one is invalidated.

    What is the max inactive time for refresh token? ›

    Refresh and session token lifetime policy properties

    Non-persistent session tokens have a Max Inactive Time of 24 hours whereas persistent session tokens have a Max Inactive Time of 90 days.

    How long is a Microsoft refresh token? ›

    A typical access token for Graph API might be around 1.5 KB, and a typical refresh token might be around 1 KB. However, these are only rough estimates, and the actual size may vary depending on the app and the user. Hope this helps.

    What is the grace period for refresh token? ›

    The default number of seconds for the Grace period for token rotation is set to 30 seconds. You can change the value to any number from 0 through 60 seconds. After the refresh token is rotated, the previous token remains valid for this amount of time to allow clients to get the new token.

    Can refresh token be used twice? ›

    When a rotated refresh token is used, a new refresh token is issued in addition to the new access token. The client application must use the most recent refresh token in the chain. All previous tokens have already been used and cannot be used again.

    How long should a refresh token live? ›

    By default, access tokens are valid for 60 days and programmatic refresh tokens are valid for a year. The member must reauthorize your application when refresh tokens expire.

    How long should a JWT refresh token last? ›

    When using the Org Authorization Server, the lifetime of the JSON Web Tokens (JWT) is hard-coded to the following values: ID Token: 60 minutes. Access Token: 60 minutes. Refresh Token: 90 days.

    How long should a token be valid? ›

    Give tokens an expiration: Technically, once a token is signed, it is valid forever—unless the signing key is changed or expiration explicitly set. This could pose potential issues so have a strategy for expiring and/or revoking tokens.

    How long does a Google refresh token last? ›

    The refresh token is set with a very long expiration time of 200 days. If the traffic to this API is 10 requests/second, then it can generate as - many as 864,000 tokens in a day.

    Top Articles
    How to access data/data folder in Android device?
    Best Alternatives to LifeLock Identity Theft Protection in 2024
    Katie Pavlich Bikini Photos
    Gamevault Agent
    Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
    Free Atm For Emerald Card Near Me
    Craigslist Mexico Cancun
    Hendersonville (Tennessee) – Travel guide at Wikivoyage
    Doby's Funeral Home Obituaries
    Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
    Select Truck Greensboro
    Things To Do In Atlanta Tomorrow Night
    Non Sequitur
    How To Cut Eelgrass Grounded
    Pac Man Deviantart
    Alexander Funeral Home Gallatin Obituaries
    Craigslist In Flagstaff
    Shasta County Most Wanted 2022
    Energy Healing Conference Utah
    Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
    Aaa Saugus Ma Appointment
    Geometry Review Quiz 5 Answer Key
    Walgreens Alma School And Dynamite
    Bible Gateway passage: Revelation 3 - New Living Translation
    Yisd Home Access Center
    Home
    Shadbase Get Out Of Jail
    Gina Wilson Angle Addition Postulate
    Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
    Walmart Pharmacy Near Me Open
    A Christmas Horse - Alison Senxation
    Ou Football Brainiacs
    Access a Shared Resource | Computing for Arts + Sciences
    Pixel Combat Unblocked
    Cvs Sport Physicals
    Mercedes W204 Belt Diagram
    'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
    Teenbeautyfitness
    Where Can I Cash A Huntington National Bank Check
    Facebook Marketplace Marrero La
    Nobodyhome.tv Reddit
    Topos De Bolos Engraçados
    Gregory (Five Nights at Freddy's)
    Grand Valley State University Library Hours
    Holzer Athena Portal
    Hampton In And Suites Near Me
    Hello – Cornerstone Chapel
    Stoughton Commuter Rail Schedule
    Bedbathandbeyond Flemington Nj
    Free Carnival-themed Google Slides & PowerPoint templates
    Otter Bustr
    Selly Medaline
    Latest Posts
    Article information

    Author: Prof. An Powlowski

    Last Updated:

    Views: 5983

    Rating: 4.3 / 5 (44 voted)

    Reviews: 83% of readers found this page helpful

    Author information

    Name: Prof. An Powlowski

    Birthday: 1992-09-29

    Address: Apt. 994 8891 Orval Hill, Brittnyburgh, AZ 41023-0398

    Phone: +26417467956738

    Job: District Marketing Strategist

    Hobby: Embroidery, Bodybuilding, Motor sports, Amateur radio, Wood carving, Whittling, Air sports

    Introduction: My name is Prof. An Powlowski, I am a charming, helpful, attractive, good, graceful, thoughtful, vast person who loves writing and wants to share my knowledge and understanding with you.