webfox / laravel-xero-oauth2

A Laravel integration for Xero using the Oauth 2.0 spec
MIT License
50 stars 32 forks source link

Xero gets disconnected automatically #22

Closed bilalswiftsolutions closed 4 years ago

bilalswiftsolutions commented 4 years ago

We have Integrated Xero with our app . but it gets disconnected any time automatically . what could be the reason? We are not storing zero credentials in database . do we need to do that?

hailwood commented 4 years ago

This package currently stores the credentials in the cache, it could be that your cache is getting automatically expunged.

What cache driver are you using?

bilalswiftsolutions commented 4 years ago

we are using default laravel cache.

bilalswiftsolutions commented 4 years ago

it means that when we run command like php artisan cache:clear or php artisan config:clear then we need to reconnect xero ?

hailwood commented 4 years ago

config:clear should be fine, but yes, cache:clear will definitely wipe it.

If you have any ideas on a different place to store the keys please let me know.

bilalswiftsolutions commented 4 years ago

In my Opinion credentials should be stored in database instead of cache . so we can load it any time. and also we can update it with reconnection

bilalswiftsolutions commented 4 years ago

Second solution

add a config file for them which loads them from the .env file. You can largely mimic the database credential infrastructural for this. This allows you to isolate the information in a single file, and keep them out of git completely. It also allows you to modify them per environment if you have a separate endpoint and/or credentials for the api which you can use in local or any uat environments.

.env:

    THIRD_PARTY_API_USERNAME=test
    THIRD_PARTY_API_PASSWORD=test

config/third-party.php

<?php

    return [
      'username' => env('THIRD_PARTY_API_USERNAME', null),
      'password' => env('THIRD_PARTY_API_password', null),
    ];

usage:

    $password = config('third_party.username');
hailwood commented 4 years ago

Storing the keys in the .env file wouldn't work as we'd need write access to the .env file. Same for any config files. We could potentially store it in a json file under storage but I'd prefer not to.

A database table could work that ties in with issue #8 Closing this issue in favour of storing it there. Please :+1: that issue.