Я использую версию сообщества, работающую на моем собственном сервере CentOS.
Шаги, которые я выполняю для использования API:
- Создайте пользователя с ролью администратора в панели администратора Magento
< li>Создать новую интеграцию - Активировать интеграцию (после этого я получаю ConsumerKey, ConsumerSecret, AccessToken, SecretToken)
Код: Выделить всё
{
Client is not authorized to access this resource: ResourceName
}
Код: Выделить всё
request({
url: this.url+endpoint,
method: 'GET',
headers:{
'Authorization': 'Bearer '+bearer,
'User-Agent': '...',
'Accept' : 'application/json',
'Content-Type': 'application/json'
}
}, (error, response, body) => {
callback(error,response,body)
})
})
Код: Выделить всё
request({
url: this.url+'integration/admin/token',
method: 'POST',
json:{
username: this.username,
password: this.password
}
}, (error, response, body) => {
callback(body)
})
Код: Выделить всё
public function isAllowed($resource, $privilege = null)
{
return $this->_aclPolicy->isAllowed($this->_aclRoleLocator->getAclRoleId(), $resource, $privilege);
}
Код: Выделить всё
return true
Я проверил функция
Код: Выделить всё
getAclRoleId()
Код: Выделить всё
namespace Magento\Framework\Authorization\RoleLocator;
class DefaultRoleLocator implements
\Magento\Framework\Authorization\RoleLocatorInterface
{
/**
* Retrieve current role
*
* @return string
*/
public function getAclRoleId()
{
return '';
}
}
Даже аутентификация oauth не работает.
Мне нужно изменить эту функцию?
Мне нужно создать еще один класс RoleLocator?
Буду очень признателен за любую помощь!
Подробнее здесь: https://stackoverflow.com/questions/486 ... 2-rest-api
Мобильная версия