getgrav / grav-premium-issues

Official Grav Premium Issues repository to report problems or ask questions regarding the Premium products offered.
https://getgrav.org/premium
7 stars 2 forks source link

[instagram-feed] Instagram token not refreshing #281

Open ghost opened 2 years ago

ghost commented 2 years ago

v1.0.0

I am finding that after 3 months the Instagram feed disappears. I have to manually refresh the token. Scheduler is set up and enabled. I suspect the problem is that for the scheduler to work you need to be actually logged into your Instagram account (?). When I click on refresh token it asks me to login, then I am able to select "allow" and it is all working again.

I work with a number of clients with Instagram and I never know who I will be logged in as, at any given time. I'm sure there will be other devs who want to use this plugin on multiple sites with multiple Instagram accounts.

MattAppleton commented 2 years ago

Same here — I currently see an 'invalid token' message... and am unable to login to instagram from the plugin admin, I see this message:

{"error_type": "OAuthException", "code": 400, "error_message": "Invalid scope: []"}

MattAppleton commented 2 years ago

If I login to the relevant account it does successfully refresh if I hit the admin 'login to instagram' button again... mind you the feed itself seems to have disappeared... investigating further...

FabriceJoseph commented 2 years ago

I have the same issue : {"error_type": "OAuthException", "code": 400, "error_message": "Invalid scope: []"}. [update] It works fine when Facebook app is in development mode. So that issue seems to come from Facebook side when the app is in live mode.

rhukster commented 2 years ago

Ok will investigate this further. an invalid scope seems to indicate something with oauth has changed.

w00fz commented 2 years ago

Can you guys check that your redirect URL has a trailing forward slash /?

CleanShot 2022-06-20 at 16 13 09@2x

I've noticed some oddities in an old setup I had, sounded like what you all have been reporting and this might be a regression in Grav. Adding the trailing / fixed it for me.

Can you confirm?

ghost commented 2 years ago

No, I have no trailing slash. url

w00fz commented 2 years ago

Can you try adding it and see if that resolves the issue?

ghost commented 2 years ago

OK. I think it is due to refresh some time next month so will see what happens. There is no other way to test is there?

w00fz commented 2 years ago

There is a CLI bin/plugin instagram-feed refresh-token you might be able to try.

ghost commented 2 years ago

No, don't have access to command line. Just realised it is 60 day expiry (I thought it was 3 months) so it should be coming up soon. I posted on 26 April. Will see how it goes.

FabriceJoseph commented 2 years ago

Hi w00fz Thank you for your response. As I said in my previous post, I succeed to refresh the token by changing live mode in development mode on Facebook app. Concerning your suggestion, I have no trailing slash too. Well I've just tested the refresh-token CLI with and without the trailing slash and the both work. So I don't think that is the problem.

MattAppleton commented 2 years ago

Still not working here

Mind you this admin screen doesnt look right, it should be showing the token and a 'valid Token' notification according to your docs if Im right?

— perhaps its the template? I am trying to call it like so:

<div id="instagram-feed" class="border-l border-t flex flex-row flex-wrap justify-center">

    {% for image in instagram.getInstagramMedia(12, false).all %}

        {% set image_src = image.cropZoom(600,600).url %}
        {% set image_url = image.meta.permalink %}

        <div class="w-1/2 md:w-1/3 lg:w-1/4 border-r border-b">
            <a class="" href="{{ image_url }}" target="_blank">
                <img style="display: inline-block;" src="{{ image_src }}" />
            </a>
        </div>

    {% endfor %}

    </div>

I get a very empty div! Example here on this page: https://www.tarmachancafe.com

rhukster commented 2 years ago

try the basic one first:

{% for image in instagram.getInstagramMedia %}
    <img style="display: inline-block;" src="{{ image.cropZoom(300, 200).url }}" />
{% endfor %}
MattAppleton commented 2 years ago

It's working again now!

Template is fine, it was the auth process that was bunging things up — logging back into Facebook developer there was something called 'Data use Checkup' that I needed to do...?!

God I hate Facebook.

MattAppleton commented 2 years ago

thanks @w00fz and @rhukster for making a thing that helps smooth some of this out...

MattAppleton commented 2 years ago

I DONT have a trailing slash by the way...

mzryz commented 1 year ago

Just chiming in, I also use this plugin and it isn't automatically re-authorising either. I just tried adding a trailing slash. Is it anything to do with my Instagram needing 2factor authentication on login I wonder? Does the plugin API get around that?