magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.57k stars 9.32k forks source link

The consumer isn't authorized to access %resources. Magento 2.4.7 on staging environment with auth1.0 #39289

Open mohitgohel80 opened 1 month ago

mohitgohel80 commented 1 month ago

Preconditions and environment

Steps to reproduce

URL: https://dev2.example.com/rest/V1/products/apitest This in headers: Authorization: "Bearer "

Expected result

Using the Token we are trying to update or delete the product, But we are getting consumer isn't authorized message.

We tried multiple ways but could not succeed.

Actual result

{"message":"The consumer isn't authorized to access %resources.","parameters":{"resources":"Magento_Catalog::products"},"trace":"#0 public_html/vendor/magento/module-webapi/Controller/Rest/RequestValidator.php(92): Magento\Webapi\Controller\Rest\RequestValidator->checkPermissions(Object(Magento\Webapi\Controller\Rest\Router\Route\Interceptor))\n#1 public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest\RequestValidator->validate()\n#2 public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\RequestValidator\Interceptor->_callParent('validate', Array)\n#3 public_html/vendor/magento/module-re-captcha-webapi-rest/Plugin/RestValidationPlugin.php(83): Magento\Webapi\Controller\Rest\RequestValidator\Interceptor->Magento\Framework\Interception{closure}()\n#4 public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\ReCaptchaWebapiRest\Plugin\RestValidationPlugin->aroundValidate(Object(Magento\Webapi\Controller\Rest\RequestValidator\Interceptor), Object(Closure))\n#5 public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\RequestValidator\Interceptor->Magento\Framework\Interception{closure}()\n#6 publichtml/generated/code/Magento/Webapi/Controller/Rest/RequestValidator/Interceptor.php(23): Magento\Webapi\Controller\Rest\RequestValidator\Interceptor->callPlugins('validate', Array, NULL)\n#7 public_html/vendor/magento/module-webapi/Controller/Rest/InputParamsResolver.php(108): Magento\Webapi\Controller\Rest\RequestValidator\Interceptor->validate()\n#8 public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest\InputParamsResolver->resolve()\n#9 public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\InputParamsResolver\Interceptor->_callParent('resolve', Array)\n#10 public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\InputParamsResolver\Interceptor->Magento\Framework\Interception{closure}()\n#11 publichtml/generated/code/Magento/Webapi/Controller/Rest/InputParamsResolver/Interceptor.php(23): Magento\Webapi\Controller\Rest\InputParamsResolver\Interceptor->callPlugins('resolve', Array, Array)\n#12 public_html/vendor/magento/module-webapi/Controller/Rest/SynchronousRequestProcessor.php(85): Magento\Webapi\Controller\Rest\InputParamsResolver\Interceptor->resolve()\n#13 public_html/vendor/magento/module-webapi/Controller/Rest.php(201): Magento\Webapi\Controller\Rest\SynchronousRequestProcessor->process(Object(Magento\Framework\Webapi\Rest\Request\Proxy))\n#14 public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Webapi\Controller\Rest->dispatch(Object(Magento\Framework\App\Request\Http))\n#15 public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Webapi\Controller\Rest\Interceptor->_callParent('dispatch', Array)\n#16 public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Webapi\Controller\Rest\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Request\Http))\n#17 publichtml/generated/code/Magento/Webapi/Controller/Rest/Interceptor.php(23): Magento\Webapi\Controller\Rest\Interceptor->callPlugins('dispatch', Array, Array)\n#18 public_html/vendor/magento/framework/App/Http.php(116): Magento\Webapi\Controller\Rest\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))\n#19 public_html/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\App\Http->launch()\n#20 public_html/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\App\Http\Interceptor->_callParent('launch', Array)\n#21 public_html/vendor/magento/module-application-performance-monitor/Plugin/ApplicationPerformanceMonitor.php(38): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception{closure}()\n#22 public_html/vendor/magento/framework/Interception/Interceptor.php(135): Magento\ApplicationPerformanceMonitor\Plugin\ApplicationPerformanceMonitor->aroundLaunch(Object(Magento\Framework\App\Http\Interceptor), Object(Closure))\n#23 public_html/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\App\Http\Interceptor->Magento\Framework\Interception{closure}()\n#24 publichtml/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http\Interceptor->callPlugins('launch', Array, NULL)\n#25 public_html/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch()\n#26 public_html/pub/index.php(30): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))\n#27 {main}"}

Additional information

We have already setting this refer below snapshot for same!

image


image


Release note

No response

Triage and priority

m2-assistant[bot] commented 1 month ago

Hi @mohitgohel80. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce.

m2-assistant[bot] commented 1 month ago

Hi @engcom-Bravo. 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:

engcom-Bravo commented 2 weeks ago

Hi @mohitgohel80,

Thanks for your reporting and collaboration.

We have verified the issue in Latest 2.4-develop instance and the issue is not reproducible.Kindly refer the screenshots.

Screenshot 2024-11-07 at 11 11 50

We are able to update and delete the products successfully.Could you please check the user having restricted access and also check authorization token.

Thanks.

mohitgohel80 commented 2 weeks ago

Hello @engcom-Bravo

Thank you for your response. I have checked and confirmed that the user is not restricted in any way. Additionally, I verified that the token key works correctly with the GET method. However, we are experiencing issues with the PUT and DELETE methods. Our server is running on Apache, and we have attempted to modify the .htaccess file. We also checked the configurations for mod_security and cross-origin security.

Furthermore, I would like to inform you that we suspected the issue might be caused by other extensions or themes. To investigate further, we created a new environment where we installed Magento 2.4.7 and updated it to patch 3. Unfortunately, we are encountering the same issues in this environment as well.

This is the new environment along with Magento 2.4.7-p3: image

The below screenshot is of the main Environment that we are working and has Magneto 2.4.7: image

Looking forward to hearing from you ASAP!

engcom-Bravo commented 1 week ago

Hi @mohitgohel80,

Thanks for your update.

Could you please also check if any third party modules can causing the issue and also confirm you are using postman in browser or you have installed app.

Screenshot 2024-11-11 at 10 05 03

Thanks.

mohitgohel80 commented 1 week ago

Hello @engcom-Bravo

We are using the Postman installed app, and we have not added any third-party extensions or themes; it’s a fresh installation.

Please let me know your conclusions.

Thanks!

engcom-Bravo commented 1 day ago

Hi @mohitgohel80,

Thanks for your update.

We have verified the issue in Latest Magento instance(2.4-develop and 2.4.8-beta1) and the issue is not reproducible.Kindly refer the screenshots.

Screenshot 2024-11-20 at 09 59 21 Screenshot 2024-11-20 at 09 59 44

Could you please verify whether user having access to the Catalog.

Thanks.