skip to Main Content

In Magento 2, customer tokens expire after an hour and the user is forced to login again. Is there a way to refresh the token?

The docomentation of mangeto does not specify such a mechanism. I am developing a mobile application and I want the customer to be logged as longer as possilbe.

2

Answers


  1. You could increase cookie lifetime which can be found in Admin Backoffice at Stores > Configuration > General > Web > Default Cookie Settings section
    Make sure you switch the scope from Default Config to either Website or Store View if you have multiple stores.

    See Magento docs for more info.

    Edit:

    I just realised that you are talking about OAuth tokens and not sessions. If that’s the case, you still need to edit one value in config, which can be found at Stores > Configuration > Services > OAuth > Access Token Expiration section

    Docs.

    Login or Signup to reply.
  2. If you are using JWT tokens, you can figure out exactly when the token is going to expire. See the reference here

    Using this you can add custom logic to trigger before the expiration. Not sure if this is the proper way to achieve what you are asking, but you can give it a try.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search