Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting invalid_code Error. Token not refreshing. #14

Open
abdulmoiz29 opened this issue Mar 28, 2023 · 11 comments
Open

Getting invalid_code Error. Token not refreshing. #14

abdulmoiz29 opened this issue Mar 28, 2023 · 11 comments

Comments

@abdulmoiz29
Copy link

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.

refresh_token
image
image

@abdulmoiz29
Copy link
Author

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.

@aemaddin
Copy link
Contributor

What is your php version?

@abdulmoiz29
Copy link
Author

Php version is 8.2.0

@aemaddin
Copy link
Contributor

I think the problem is caused by PHP 8.2, so please try the package with PHP 8.1.

@aemaddin
Copy link
Contributor

There is a problem with the core SDK by Zoho not being compatible with PHP 8.2

@1337erik
Copy link

1337erik commented Apr 6, 2023

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

image

image

@1337erik
Copy link

1337erik commented Apr 7, 2023

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

@jaketoolson
Copy link
Contributor

jaketoolson commented Apr 16, 2023

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()```

@jayomayan
Copy link

has this been resolved? i'm experiencing the same.

@upsmod
Copy link
Contributor

upsmod commented Jun 30, 2023

So i have just catching a refreshToken - inside txt file - but it not works, grantToken or accessToken not refreshed
php 8.2

@upsmod upsmod mentioned this issue Jun 30, 2023
@upsmod
Copy link
Contributor

upsmod commented Jul 2, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants