Open Closed

Refresh Problem When Token Expires #6196


User avatar
0
Teknosol created
  • ABP Framework version: v7.1.1

  • UI Type: Angular

  • Database System: EF Core (PostgreSQL)

  • Tiered (for MVC) or Auth Server Separated (for Angular): yes

  • Exception message and full stack trace:

  • Steps to reproduce the issue:

Hello, we use ABP Framework in the back-end part of our project and Angular in the front-end part. We chose to use the login structure offered by ABP for login operations. We specifically included it in our Angular project. We are faced with the situation of refreshing the page when the access token expires. However, we do not want this renewal to happen. How can we achieve this?

Ekran görüntüsü 2023-11-20 111024.png
Ekran görüntüsü 2023-11-20 111034.png
Ekran görüntüsü 2023-11-20 111209.png
Ekran görüntüsü 2023-11-20 133645.png
Ekran görüntüsü 2023-11-20 133707.png


12 Answer(s)
  • User Avatar
    1
    Anjali_Musmade created
    Support Team Member
  • User Avatar
    0
    Teknosol created

    Hi,
    As far as we understand, you suggested a solution to redirect to the login page when the token expires. However, our problem is about being able to continue working without refreshing the page when the token expires. Do you have any suggestions on how we can continue working on the project without redirecting to another page or blocking the operation when the token expires?

  • User Avatar
    1
    Anjali_Musmade created
    Support Team Member
  • User Avatar
    0
    Teknosol created

    Hi,
    As stated in the examples you posted, we wanted to turn off the offline_access feature. But we do not use the offline_access feature in our project anyway. If you have another solution, we ask you to share it.

  • User Avatar
    1
    Anjali_Musmade created
    Support Team Member

    Hi,

    Could you please check this similar issue https://support.abp.io/QA/Questions/6007
    I think this will solve your issue.

    Thanks,
    Anjali

  • User Avatar
    0
    Teknosol created

    Hi,
    We added the red marked code block above to the auth server host module. Where should we add the code block in the blue box below?
    image.png

  • User Avatar
    1
    Anjali_Musmade created
    Support Team Member

    Hi,

    For code in the blue block, create a new class file named MyLoginModel used for customizing LoginModel and add that code to that newly created class.

    regards,

  • User Avatar
    0
    Teknosol created

    Hi,
    It didn't work for our project. we took a screen video for the error. For example, when filling out a form on a screen, when the access token expires, the page is refreshed and the page is redirected to the dashboard, we want the page to stay in the current form without refreshing and get a refresh token.

    In addition, when the token expires and refreshes on the page, the token is received from openidict again and I share these sample token records in the screenshot. There is no record in the table as a refresh token for types, can we not generate any refresh token?

    I kindly ask for your support.

    Error Video : https://we.tl/t-KtB8yfhfI3
    image.png

  • User Avatar
    0
    Anjali_Musmade created
    Support Team Member

    Hello,

    Apologies for delay, have you checked this documentation https://docs.abp.io/en/commercial/7.4/modules/openiddict#refresh-token

  • User Avatar
    0
    Teknosol created

    Hi,
    We tried your suggestion but we were not successful. Do you have a sample project where we can see this scenario? Is there a refresh token application in eshop or bookstore?

  • User Avatar
    0
    alper created
    Angular Developer

    Hi, have you tried the check remember me button?

    image.png

    this attribute is excatly what you need in your case

  • User Avatar
    0
    alper created
    Angular Developer

    Hi,
    As far as we understand, you suggested a solution to redirect to the login page when the token expires. However, our problem is about being able to continue working without refreshing the page when the token expires. Do you have any suggestions on how we can continue working on the project without redirecting to another page or blocking the operation when the token expires?

    • this is wrong, normally when the access_token expires, you get a new generated access_token via refresh_token. the application shouldn't be redirect you to login page again.

    • in version 7.1.1 i have created a new application with this command;

      • abp new -t app-pro -u angular

      • and set accesstoken expire date to 5 seconds;

    • here is how the token regenerated; this is the normal behavior.

    token.gif

    • make sure about your configurations in environment file

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.3.0-preview. Updated on April 07, 2025, 05:26