authenticationmagento2access-tokenbearer-tokenrefresh-token

Is there any way to refresh customer access tokens in magento 2


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.


Solution

  • 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.