eileenmcnaughton / nz.co.fuzion.civixero

Synchronisation between CiviCRM & Xero
7 stars 14 forks source link

authorization expiry #122

Closed Upperholme closed 1 year ago

Upperholme commented 1 year ago

Every morning when I log in to my site (D7) with the up to date versions of this extension and the account sync extension installed, I'm presented with the warning that the CiviXero authorisation has expired and that I need to renew it. I go to the page on my site - /civicrm/xero/authorize?connector_id=0 and it reports that everything is fine. Which is correct?

mattwire commented 1 year ago

@Upperholme Yes the logic for the status message isn't quite right I think - it seems to throw up too many false positives.

Upperholme commented 1 year ago

Currently running Civi 5.60.0 and CiviXero 2.1.2 - and the authorization appears to be regularly expiring where i would expect it to keep itself up to date. I'm manually re-authorizing multiple times per day, but this clearly is not ideal and not sustainable. If there's something I need to have done to resolve this then I'm all ears.

Upperholme commented 1 year ago

Still struggling with authorisation expiry.

I've now updated a second site (Wordpress) to the 2.1.2 CiviXero release and it looks to be having the same problems as my other site, which is D7. Both sites are on a server running PHP 7.3 (don't know if that is a possible cause).

On both sites I see the same behaviour: CiviXero very regularly reports that the authorisation has expired. I've not done any tests on this but it is my assumption that it is not renewing the authorisation once I have set it via https://mydomain.com/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fxero%2Fauthorize or in the case of the D7 site https://myotherdoamin.com/civicrm/xero/authorize

I'm also seeing a weird issue which I assume is linked whereby on many occasions when I click on the link to reauthorise I get a fatal error.

On the Wordpress sites this looks like:

PHP Fatal error: Uncaught TypeError: Return value of CRM_Civixero_OAuth2_TokenStoreDefault::getConnectorID() must be of the type int, null returned in /home/vcare/sites/default/wp-content/uploads/civicrm/ext/nz.co.fuzion.civixero/CRM/Civixero/OAuth2/TokenStoreDefault.php:34\nStack trace:\n

0 /home/vcare/sites/default/wp-content/uploads/civicrm/ext/nz.co.fuzion.civixero/CRM/Civixero/OAuth2/TokenStoreDefault.php(52): CRM_Civixero_OAuth2_TokenStoreDefault->getConnectorID()\n

1 /home/vcare/sites/default/wp-content/uploads/civicrm/ext/nz.co.fuzion.civixero/CRM/Civixero/OAuth2/Xero.php(122): CRM_Civixero_OAuth2_TokenStoreDefault->save(Object(League\OAuth2\Client\Token\AccessToken))\n

2 /home/vcare/sites/default/wp-content/uploads/civicrm/ext/nz.co.fuzion.civixero/CRM/Civixero/Form/XeroAuthorize.php(78): CRM_Civixero_OAuth2_Xero->getToken()\n

3 /home/vcare/sites/default/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(673): CRM_Civixero_Form_XeroAuthorize->preProcess()\n

4 /home/vcare/sites/d...', referer: https://www.domain.com/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fa%2F

Looking in my database I can see in the civicrm_setting table that the value for xero_access_token is NULL. ~

eileenmcnaughton commented 1 year ago

I'm not too sure about the expiring but I found a reason for the 'PHP Fatal error: Uncaught TypeError:' you report & tagged 2.1.3 with a fix for that error

Upperholme commented 1 year ago

I was able to update to 2.1.3 - many thanks for making that available - at the weekend, and it appears to have resolved the problem I was facing where it was not automatically reneweing the access token. Which is fabulous!

eileenmcnaughton commented 1 year ago

woohoo - I think I can close this then!