2

I tried to change the default customer access token expiration from 1 hour to 48 hours and even to 0 to disable expiration, but regardless of what number I enter, the token I receive from the REST API expires in 1 hour. I cleaned the cache, flushed it.

What can I do to make Magento use the numbers I enter? (Magento 2.4.4)

My current settings in Magento

This is how the API request looks like:

POST https://elszerbt.alphadev.hu/rest/default/V1/integration/customer/token
Accept: application/json
Content-Type: application/json

{"username": "[email protected]", "password": "mypassword"}

The customer has been added manually and the password setup through the activation email link. This test customer is the only one right now:

List of customers

The token works perfectly once it's received, but it expires early. You can see the token here:

eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MywiaWF0IjoxNjYwNzI5ODQ0LCJleHAiOjE2NjA3MzM0NDR9.fxnGiLwFNc4dAZA0-npEsAf0gzpnU1pKXZke78WFuOM

If you enter this token to https://jwt.io/, you can see the difference between the issue date and expiration date is 1 hour.

I also tested the admin token the following way:

POST https://elszerbt.alphadev.hu/rest/default/V1/integration/admin/token
Accept: application/json
Content-Type: application/json

{"username": "adminuser", "password": "mypassword"}

What's interesting is that it also expires in 1 hour, which is not the default setting for admin tokens. The default is 4 hours.

This is the admin token I received:

eyJraWQiOiIxIiwiYWxnIjoiSFMyNTYifQ.eyJ1aWQiOjEsInV0eXBpZCI6MiwiaWF0IjoxNjYwNzMwMTY5LCJleHAiOjE2NjA3MzM3Njl9.dwI7qbYSe8A2BOHlLKE4KlL7QmJzlX1wYVlkoRJIhyM

I have this issue on multiple instances, although they have exactly the same setup. I'm using the default file-system cache of Magento.

2
  • 1
    are you able to add more info on how to reproduce your issue? How is the API call you make? header, body, endpoint will be useful to ensure we can replicate exactly your issue? Commented Aug 16, 2022 at 14:00
  • Hi, thanks, I added more information. Commented Aug 17, 2022 at 9:11

4 Answers 4

3

I found the solution. There is another setting here:

Other configuration page

I set the expiration here to 600 minutes and it works perfectly.

1

This might be a setting in your redis configuration.

please check your redis settings in your env.php.

documentation can be found here: https://experienceleague.adobe.com/docs/commerce-operations/configuration-guide/cache/redis/redis-pg-cache.html

2
  • Hi. Thanks, but I'm not using redis, the caching is set to default. Commented Aug 17, 2022 at 9:36
  • Any ideas how can I determine if it's a caching problem? Commented Aug 17, 2022 at 9:45
0

The setting for the Token expiration can be found in Store/Configuration/Services/OAuth

See screenshot below,

enter image description here

2
  • No, it's not. That's my exact point. It doesn't do anything. Commented Aug 18, 2022 at 12:21
  • I believe you must have a customisation taking over this behaviour in Magento as it seems fine at my end Commented Aug 18, 2022 at 12:25
0
module:disable Magento_JwtUserToken Magento_AdobeStockAdminUi Magento_AdminAdobeIms

That will make the token not reset.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.