简体   繁体   English

在客户上进行GET / POST / PUT时,是否可以禁用/不使用Magento REST API上的oAuth?

[英]Any way to disable / not use oAuth on Magento's REST API, when GET/POST/PUT on customers?

I am new to Magento . 我是Magento新手。 Is it possible to (temporarily?) disable the requirement for oAuth in Magento and still retrieve customer data. 是否可以(临时?)在Magento禁用对oAuth的要求,并仍然检索客户数据。 through the REST API? 通过REST API?

So basically be able to issue GET, PUT requests over HTTP without using oAuth ? 因此,基本上可以在不使用oAuth情况下通过HTTP发出GET,PUT请求?

URL: http://magento/api/rest/customers?limit=2 网址: http:// magento / api / rest / customers?limit = 2

I am getting Access denied(403) error. 我收到“访问被拒绝(403)”错误。

Note: I am able to read products. 注意:我能够阅读产品。

Please try this one.may b it works. 请尝试这个。可能会起作用。

go to Magento admin panel,System->Webservices->REST Attributes->Select User type customer and select resource access as ALL and save. 转到Magento管理面板,依次选择“系统”->“ Web服务”->“ REST属性”->“选择用户类型客户”,然后选择“资源访问”作为“所有”并保存。 and check now: http://magento/api/rest/customers?limit=2 并立即检查: http:// magento / api / rest / customers?limit = 2

You can go to app/code/core/Mage/Api2/Model/Auth.php and change const DEFAULT_USER_TYPE = 'guest' to const DEFAULT_USER_TYPE = 'admin' and go to app/code/core/Mage/Api2/Model/Auth/Adapter.php and change return (object) array('type' => Mage_Api2_Model_Auth::DEFAULT_USER_TYPE, 'id' => null) to return (object) array('type' => Mage_Api2_Model_Auth::DEFAULT_USER_TYPE, 'id' => 1) . 您可以转到app / code / core / Mage / Api2 / Model / Auth.php,将const DEFAULT_USER_TYPE ='guest'更改为const DEFAULT_USER_TYPE ='admin',然后转到app / code / core / Mage / Api2 / Model / Auth /Adapter.php并更改返回(object)array('type'=> Mage_Api2_Model_Auth :: DEFAULT_USER_TYPE,'id'=> null)返回(object)array('type'=> Mage_Api2_Model_Auth :: DEFAULT_USER_TYPE,'id'= > 1)

This will set default consumer to Admin and you will be able to access all API with admin privileges. 这会将默认使用者设置为Admin,您将能够使用管理员权限访问所有API。 You can also change it to 'customer' and provide any customer id in Adapter.php. 您也可以将其更改为“ customer”,并在Adapter.php中提供任何客户ID。

You would need to give guest access to customer resources. 您需要授予访客访问客户资源的权限。

Havent tried it yet, but i would suggest you extend the module Havent尝试过了,但是我建议您扩展模块

  • copy mage/customer with etc/api2 and model/api2/customer/rest/ to local modules so you dont modify core data. 将具有etc / api2model / api2 / customer / rest /的 法师/客户复制到本地模块,以免修改核心数据。

  • then modify etc/api2 so you have access from guest calls and add attribute permissions as well 然后修改etc / api2,这样您就可以访问来宾呼叫并添加属性权限

  • add the required model on api2/customer/rest so that guest may process callbacks, im guessin that just copying the admin, rename to guest and rename class name in v1 should do the trick. api2 / customer / rest上添加所需的模型,以便guest 虚拟机可以处理回调,我猜想只需复制admin,重命名为guest 虚拟机并重命名v1中的类名即可解决问题。

Instead of oAuth you can implement your own authentication adapter for REST API in Magento. 您可以在Magento中为REST API实现自己的身份验证适配器,而不是oAuth。 You can find more details in this article . 您可以在本文中找到更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM