0

How to set Rest API oAuth token expire in minutes or seconds in admin. Currently it's showing hours and it will not accept like 0.5(for 30 minute etc) magento2. Any One know about this, please help me asap.

0

As Magento DevDocs said you can not edit this setting.

enter image description here

You have one Option Also

Step 1: Set the value as non trace able value for ex: 7856467.

Step 2: Search this value directly in DB, then edit and Save this value as 0.5

Here code is set according to hours, so if you want to set it for 15mins then, you need to calculate with formula n/60 = value

for ex - 15/60 = 0.25. 

Override This file - Path : vendor\magento\module-integration\Helper\Oauth\Data.php

And Update the Value as (need to remove (int) )

$hours = $this->_scopeConfig->getValue('oauth/access_token_lifetime/customer'); return $hours > 0 ? $hours : 0;

And Then Run Commands

php bin/magento s:up && php bin/magento s:d:c && php bin/magento s:s:d -f && php bin/magento c:c && php bin/magento c:f

so basically you need to do it like this

Hope this will solve your problem.

  • I have already installed magento2.3.2 version. My question is that how to set Rest API oAuth token expire in minutes or seconds in admin. Currently it's showing hours and it will not accept like 0.5(for 30 minute etc). – Sangeeta Chandaliya Sep 25 '19 at 5:48
  • Answer updated. – Oscprofessionals Sep 25 '19 at 6:04
  • I need to update Admin Default Lifetime to minute, it will not work if change 0.5 from database level or direct admin aswell. – Sangeeta Chandaliya Sep 25 '19 at 6:11
  • here code is set according to hours, so if you want to set it for 15mins then you need to calculate with formula n/60 = value. for ex - 15/60 = 0.25. so basically you need to do it like this – Oscprofessionals Sep 25 '19 at 6:18
  • 1
    I have updated 0 to -1 but still not work $hours = (int)$this->_scopeConfig->getValue('oauth/access_token_lifetime/customer'); return $hours > -1 ? $hours : 0; – Sangeeta Chandaliya Sep 25 '19 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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