Magento2: Not Able to set Rest API oAuth admin token expire in minutes or seconds.

Created on 25 Sep 2019  路  11Comments  路  Source: magento/magento2

Summary (*)

Not Able 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)

Preconditions (*)

  1. Magento 2.3-develop

Steps to reproduce (*)

  1. Login to Admin
  2. Go to the Stores-->Configuration-->Services-->OAuth
  3. Change values in Customer Token Lifetime (hours) & in Admin Token Lifetime (hours) to '0.5'
    image
  4. Get the admin token (POST <yourlocal>/rest/V1/integration/admin/token)
    image
  5. Notice the time when you sent the request
    image
  6. Wait 30+ minutes
  7. Send any request with admin token ( GET <yourlocal>/rest/V1/products/<sku> in my case)

Expected result (*)

  1. We get an error
    image

Actual result (*)

200 OK
image

Api Fixed in 2.3.x Clear Description Format is valid

All 11 comments

Hi @sangeetajain. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • [ ] Summary of the issue
  • [ ] Information on your environment
  • [ ] Steps to reproduce
  • [ ] Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@sangeetajain do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • [ ] yes
  • [ ] no

Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

  • [ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.
  • [ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • [ ] 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • [ ] 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 5. Add label Issue: Confirmed once verification is complete.

  • [ ] 6. Make sure that automatic system confirms that report has been added to the backlog.

Hello @sangeetajain
I can't reproduce this issue on a fresh Magento 2.3-develop.

Manual testing scenario:

  1. Login to Admin
  2. Go to the Stores-->Configuration-->Services-->OAuth
  3. Change values in Customer Token Lifetime (hours) & in Admin Token Lifetime (hours) to '0.5'

Actual result:
Configuration is saved
image

So i have to close this issue. If you have some updates left a comment please.
Thanks for your report!

0.5 is save but it will not work on practically. Like if we set 0.5 means token will expire after 30 minute by logic but in Magento 2.3 it's not happen.
If we put 0.5 that means it will check $hour > 0 then it will set 0 hour which is never expire toke.

Hello @sangeetajain
I can't reproduce this issue on a fresh Magento 2.3-develop.

Manual testing scenario:

  1. Login to Admin
  2. Go to the Stores-->Configuration-->Services-->OAuth
  3. Change values in Customer Token Lifetime (hours) & in Admin Token Lifetime (hours) to '0.5'

Actual result:
Configuration is saved
image

So i have to close this issue. If you have some updates left a comment please.
Thanks for your report!

0.5 is save but it will not work on practically. Like if we set 0.5 means token will expire after 30 minute by logic but in Magento 2.3 it's not happen.
If we put 0.5 that means it will check $hour > 0 then it will set 0 hour which is never expire token.

@sangeetajain you are right. I will update a description of issue and confirm it.

:white_check_mark: Confirmed by @engcom-Charlie
Thank you for verifying the issue. Based on the provided information internal tickets MC-20487 were created

Issue Available: @engcom-Charlie, _You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself._

Hi @ivan-koliadynskyy. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

  • [ ] 1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
  • [ ] 2. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and _stop verification process here_!

  • [ ] 3. If the issue is not relevant or is not reproducible any more, feel free to close it.


@sangeetajain there is no bug here. Hours are supposed to be integer and config works as expected.

What is the use case to have token expiry less than 1 hour?

@ivan-koliadynskyy : Thank you for the updated code.
Just Suggestion that In admin side it's captured the string value in input filed which is not correct thing, because it should take only number then it's better.
download

Hi @sangeetajain. Thank you for your report.
The issue has been fixed in magento/magento2#24769 by @ivan-koliadynskyy in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.4 release.

Was this page helpful?
0 / 5 - 0 ratings