genxbe / kirby3-instagram

Fetch instagram photos without the need for app aproval
MIT License
50 stars 1 forks source link

Instagram credentials are not stored in site.txt on server #7

Open lmgringhuis opened 2 years ago

lmgringhuis commented 2 years ago

When tested on local everything seems to work perfectly. However, when placed on a testing server, the Instagram credentials are not saved in the site.txt file, only the refreshed date:

Instagramauth: 

----

Instagramtoken: 

----

Instagramtokenrefreshed: 2022-08-08

The test server is running the same 3.7.0.1 Kirby instance and is running on PHP 8.1. Any idea why this is not working?

lmgringhuis commented 2 years ago

It seems that the catch is triggered in the fetch function, even if the call was succesfull. Doing that it overwrites the Instagram credentials:

catch(\Exception $e)
        {
            site()->update([
                'instagramAuth' => (boolean)false,
                'instagramToken' => '',
            ]);
        }

If I add this the credentials are stored:

catch(\Exception $e)
        {
            die(var_dump($e));
        }

The exception isn't shown. Have to put some extra logging in place to see what happens. Very strange that this is not happening on my local dev environment.

lmgringhuis commented 2 years ago

Extra logging on the exception below. I tried some debugging myself but can't really understand this error, because the values are there and are set.. Everything works perfectly if I prevent the exception catch from triggering.

Whoops\Exception\ErrorException: Undefined array key "access_token" in /site/plugins/kirby3-instagram/classes/Instagram.php:59
Stack trace:
#0 /site/plugins/kirby3-instagram/classes/Instagram.php(59): Whoops\Run->handleError()
#1 /site/plugins/kirby3-instagram/index.php(21): X\Instagram->getToken()
#2 [internal function]: Kirby\Http\Route->{closure}()
#3 /kirby/src/Http/Router.php(131): Closure->call()
#4 /kirby/src/Cms/App.php(337): Kirby\Http\Router->call()
#5 /kirby/src/Cms/App.php(1242): Kirby\Cms\App->call()
#6 /index.php(5): Kirby\Cms\App->render()
#7 {main}
samzzi commented 2 years ago

Hi @lmgringhuis I'm quite busy atm so I'll take a look at this in the coming 2 weeks. Can't reproduce though so this will be a challenge to find out. (and very strange that it still works if you remove the catch because you need an access_token from instagram to have this working 🤔)

samzzi commented 2 years ago

And already thanks for your investigation and feedback btw @lmgringhuis 😉