Open abdulmoiz29 opened 1 year ago
I found out If I create a new grant token and run zoho:install it works until access_token expires. And then it wont refresh using refresh_token. So I have to create another grant_token and do the whole process again.
What is your php version?
Php version is 8.2.0
I think the problem is caused by PHP 8.2, so please try the package with PHP 8.1.
There is a problem with the core SDK by Zoho not being compatible with PHP 8.2
I am using php 8.1 and it is not working.
When I look at my local environment which is using the SelfClient I see a refresh token generated. When I used my Server-Client on my local, it did not log a refresh token. When I look at the logs on my production server ( which uses the Server-Client only ) it also does not log a refresh token. So basically the Server client only ever lasts 1 hour until the token expires then it needs to be refreshed
It would really help to understand where within the packages authentication process it could be checked to see if a refresh token is being passed and accidentally left out, or if theres a way to insert another call to grab one
https://www.zoho.com/accounts/protocol/oauth/web-apps/authorization.html
Apparently it 'should' be getting passed back because the grant token url is set with the correct parameters, not sure where to go with this
This is happening to us too. It only happens when we use the Zoho Accounts
module. When we use the Leads
module, there is no problem. This doesn't make sense because all the tokens etc are the same. No matter what we've tried, we still get invalid_code
error. We downgraded to Php 8.1 (per above comments) and no luck. Something is broken and the stack trace doesn't really help.
Code Sample that causes the error to occur:
use Asciisd\Zoho\ZohoManager;
$accounts = ZohoManager::useModule('Accounts');
$res = $accounts->create([
'Account_Name' => $organization->name,
'Created_By' => $organization->owner->full_name
]);
Logged Exception:
2023-04-13 16:56:23 com\zoho\api\logger\SDKLogger SEVERE Exception : com\zoho\crm\api\exception\SDKException Caused by : INVALID TOKEN ERROR - invalid_code
/var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/api/authenticator/OAuthToken.php- 377- invalid_code
#0 /var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/api/authenticator/OAuthToken.php(348): com\zoho\api\authenticator\OAuthToken->processResponse()
#1 /var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/api/authenticator/OAuthToken.php(235): com\zoho\api\authenticator\OAuthToken->generateAccessToken()
#2 /var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/crm/api/util/CommonAPIHandler.php(253): com\zoho\api\authenticator\OAuthToken->authenticate()
#3 /var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/crm/api/fields/FieldsOperations.php(41): com\zoho\crm\api\util\CommonAPIHandler->apiCall()
#4 /var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/crm/api/util/Utility.php(580): com\zoho\crm\api\fields\FieldsOperations->getFields()
#5 /var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/crm/api/util/Utility.php(96): com\zoho\crm\api\util\Utility::getFieldDetails()
#6 /var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/crm/api/util/Utility.php(211): com\zoho\crm\api\util\Utility::fileExistsFlow()
#7 /var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/crm/api/util/Utility.php(170): com\zoho\crm\api\util\Utility::getFieldsInfo()
#8 /var/www/html/vendor/zohocrm/php-sdk-2.1/src/com/zoho/crm/api/record/RecordOperations.php(142): com\zoho\crm\api\util\Utility::getFields()
#9 /var/www/html/vendor/asciisd/zoho-v3/src/Concerns/ManagesActions.php(29): com\zoho\crm\api\record\RecordOperations->createRecords()
#10 /var/www/html/src/OrganizationZohoSync.php(23): Asciisd\Zoho\ZohoManager->create()```
has this been resolved? i'm experiencing the same.
So i have just catching a refreshToken - inside txt file - but it not works, grantToken or accessToken not refreshed php 8.2
That problem was infected only when i use serverside client on the zoho. make self client generate token. copy-paste to ZOHO_TOKEN and make php artisan zoho:grant
I have setup a server side Client in zoho and set everything up. Everything was done Successfully but after I add my code generated by php artisan zoho:authentication following this link in ENV it genrates a empty file after php artisan zoho:grant and when I try to get data from ZOHO it gives me invalid_code. Screen Shots are attached. And few days back it was genrating refresh token and everything perfectly.