Skip to main content
added 127 characters in body
Source Link
Pasha
  • 65
  • 1
  • 8

I need to do API method, which return data from db table just for admin. There is my method:

/**
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function showAddedSku()
    {
        $insSku = $this->collection->create();
        $data = [];

        foreach ($insSku as $key => $sku)
        {
            $data[$key]['id'] = $sku->getId();
            $data[$key]['sku'] = $sku->getSku();
            $data[$key]['count'] = $sku->getCount();
        }

        return $data;
    }

How can I check, that it is admin?

I read, that I must set that:

<resources>
    <resource ref="???" />
</resources>

but what ref should i choose?

I need to do API method, which return data from db table just for admin. There is my method:

/**
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function showAddedSku()
    {
        $insSku = $this->collection->create();
        $data = [];

        foreach ($insSku as $key => $sku)
        {
            $data[$key]['id'] = $sku->getId();
            $data[$key]['sku'] = $sku->getSku();
            $data[$key]['count'] = $sku->getCount();
        }

        return $data;
    }

How can I check, that it is admin?

I need to do API method, which return data from db table just for admin. There is my method:

/**
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function showAddedSku()
    {
        $insSku = $this->collection->create();
        $data = [];

        foreach ($insSku as $key => $sku)
        {
            $data[$key]['id'] = $sku->getId();
            $data[$key]['sku'] = $sku->getSku();
            $data[$key]['count'] = $sku->getCount();
        }

        return $data;
    }

How can I check, that it is admin?

I read, that I must set that:

<resources>
    <resource ref="???" />
</resources>

but what ref should i choose?

edited title
Link
Pasha
  • 65
  • 1
  • 8

How to check is valid token or nonot. Magento 2 API

Source Link
Pasha
  • 65
  • 1
  • 8

How to check is valid token or no. Magento 2 API

I need to do API method, which return data from db table just for admin. There is my method:

/**
     * @return array
     * @throws \Magento\Framework\Exception\LocalizedException
     */
    public function showAddedSku()
    {
        $insSku = $this->collection->create();
        $data = [];

        foreach ($insSku as $key => $sku)
        {
            $data[$key]['id'] = $sku->getId();
            $data[$key]['sku'] = $sku->getSku();
            $data[$key]['count'] = $sku->getCount();
        }

        return $data;
    }

How can I check, that it is admin?