简体   繁体   English

自定义REST API在Magento中有403错误

[英]custom rest api have 403 error in magento

i have create a custom rest api in magento. 我已经在magento中创建了一个自定义的rest api。 it is working fine if i access via this code : 如果我通过此代码访问,则工作正常:

http://www.magentocommerce.com/api/rest/introduction.html http://www.magentocommerce.com/api/rest/introduction.html

But when i want to access this using this url : 但是,当我想使用此网址访问此文件时:

host/api/rest/datafeed/truedash_customers 主机/ api / rest / datafeed / truedash_customers

it is give me an error : 这是一个错误:

403 Access denied 403访问被拒绝

can any one tell me why this happen any help please...... 任何人都可以告诉我为什么会发生这种情况吗……

1) Quick and dirty fix: in the file /app/code/core/Mage/Api2/Model/Auth.php, change the value of: DEFAULT_USER_TYPE = 'guest' to DEFAULT_USER_TYPE = 'admin'. 1)快速修复:在文件/app/code/core/Mage/Api2/Model/Auth.php中,将以下值更改:DEFAULT_USER_TYPE ='guest'到DEFAULT_USER_TYPE ='admin'。

In the file /app/code/core/Mage/Api2/Model/Auth/Adapter.php, change this line from return (object) array('type' => Mage_Api2_Model_Auth::DEFAULT_USER_TYPE, 'id' => null); 在文件/app/code/core/Mage/Api2/Model/Auth/Adapter.php中,从返回(对象)数组更改此行('type'=> Mage_Api2_Model_Auth :: DEFAULT_USER_TYPE,'id'=> null); to this: return (object) array('type' => Mage_Api2_Model_Auth::DEFAULT_USER_TYPE, 'id' => '1'); 为此:返回(对象)array('type'=> Mage_Api2_Model_Auth :: DEFAULT_USER_TYPE,'id'=>'1');

This way the authentication system will not be broken. 这样,身份验证系统就不会被破坏。

2) Proper and long run fix: Override the two functionalities using the magento overriding mechanism to have a better solution in accordance to magento standards. 2)正确和长期的解决方法:使用magento覆盖机制覆盖这两个功能,以便根据magento标准提供更好的解决方案。 This way the core files will be intact. 这样,核心文件将保持完整。

  1. Quick and dirty fix: in the file /app/code/core/Mage/Api2/Model/Auth.php , change the value of: DEFAULT_USER_TYPE = 'guest' to DEFAULT_USER_TYPE = 'admin' . 快速而肮脏的修复:在文件/app/code/core/Mage/Api2/Model/Auth.php ,将以下值更改: DEFAULT_USER_TYPE = 'guest'DEFAULT_USER_TYPE = 'admin'

  2. In the file /app/code/core/Mage/Api2/Model/Auth/Adapter.php, change this line from 在文件/app/code/core/Mage/Api2/Model/Auth/Adapter.php,更改为

     return (object) array('type' => Mage_Api2_Model_Auth::DEFAULT_USER_TYPE, 'id' => null); 

    to this: 对此:

      return (object) array('type' => Mage_Api2_Model_Auth::DEFAULT_USER_TYPE, 'id' => '1'); 

This way the authentication system will not be broken. 这样,身份验证系统就不会被破坏。

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

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