invalid oauth token

invalid oauth token

Hi,

I'm trying to make an API call to add data to a custom view in Leads scope. I'm getting grant token, refresh token and access token successfully with help of curl call and than PHP SDK. My problem is when I want to get Leads fields I get 'invalid oauth token' message. My user has restricted access, I only see the custom view in top navigation when accessing ZohoCRM with my user.

Code I'm trying to use to retrieve field values is:
  1. $config = [
  2.     'client_id' => $clientId,
  3.     'client_secret' => $clientSecret,
  4.     'redirect_uri' => $redirectUri,
  5.     'currentUserEmail' => $userEmailId,
  6.     'applicationLogFilePath' => $this->applicationLogFilePath,
  7.     'token_persistence_path' => $this->tokenPersistencePath,
  8.     'accounts_url' => $this->accountsUrl
  9. ];
  10. \ZCRMRestClient::initialize($config);
  11. $zcrmIns = \ZCRMRestClient::getInstance();
  12. $zcrmAPIResponse = $zcrmIns->getModule('Leads');
  13. $zcrmModule = $zcrmAPIResponse->getData();
  14. $zcrmFields = $zcrmModule->getAllFields()->getData();
Code I'm trying to use to insert new record is:
  1. \ZCRMRestClient::initialize($config);
  2. $record=\ZCRMRecord::getInstance('Leads',null);
  3. foreach ($data as $item => $value) {
  4.     $record->setFieldValue($item, $value);
  5. }
  6. $zcrmModuleIns = \ZCRMModule::getInstance('Leads');
  7. $bulkAPIResponse = $zcrmModuleIns->upsertRecords([$record]);
  8. $entityResponses = $bulkAPIResponse->getEntityResponses();
This code works by the way if I'm trying it with a newly created ZohoCRM test account created by me and with the plain 'Leads' scope but with real user to real client I have restricted access only to see custom view of 'Leads'.

Can you please help me with this somehow? I realy need to solve this somehow.

Thanks.
Best regards.