consolibyte / quickbooks-php

QuickBooks Integration for PHP
Eclipse Public License 1.0
455 stars 337 forks source link

Oauth 2 issue: Unserialized error in AES when attempting auth token refresh #286

Closed jburgoyn closed 4 years ago

jburgoyn commented 4 years ago

I have the latest commits from last week or so. After an hour of being connected via OAuth2, and another QuickBooks API call is made, the auth token is invalid, the auth token is not being refreshed. We are getting the following errors when the token refresh is attempted.

PHP Notice: unserialize(): Error at offset 0 of 904 bytes in /lib/QuickBooks/QuickBooks/Encryption/Aes.php on line 82 PHP Warning: current() expects parameter 1 to be array, boolean given in /lib/QuickBooks/QuickBooks/Encryption/Aes.php on line 83

Any help would be greatly appreciated. Thanks.

ebogdanov commented 4 years ago

Not sure 100%, but check the size of encrypted data, it's possible that it's more than DB limit.

consolibyte commented 4 years ago

Can you post the results of DESCRIBE quickbooks_oauthv2 ? And confirm that these two fields are TEXT type?

oauth_access_token
oauth_refresh_token
jburgoyn commented 4 years ago

@consolibyte thanks, here is the results of the DESCRIBE. the tokens are indeed TEXT type.

Screen Shot 2019-12-23 at 4 13 23 PM

Anything else you can think of to check?

Thanks, Jonny

jburgoyn commented 4 years ago

@ebogdanov hi, could you expound on your suggestion of checking the size of the encrypted data? Could you provide some pointers for where I could look or what I might need to change. Thanks.

ebogdanov commented 4 years ago

@jburgoyn Well, if you've TEXT as datatype, it's hard to guess now.

I've checked current "master" code and do not see any possible problems. My only one idea is that yours encryption key is some UTF-8 string?

If you use PHP 7.1+ I suggest you to check my fork with branch https://github.com/ebogdanov/quickbooks-php/tree/encryption/mcrypt-to-openssl

and see if problem still happens for you. If yes - there is only one way is step by step debugging of "refresh key workflow" on your system.

jburgoyn commented 4 years ago

@ebogdanov thank you for the help, I will check out your branch for sure. Appreciate it.