Closed simonkuran closed 1 year ago
Can you post the full stack trace if possible, thanks
On Tue, 22 Nov 2022 at 17:05, simonkuran @.***> wrote:
When Instagram redirects back to the site after I approve the authorization I get a "Undefined property: stdClass::$access_token" error. Do you know what could be causing that?
I'm running Craft v3.6.10 and Craftagram v1.4.4.
— Reply to this email directly, view it on GitHub https://github.com/scaramangagency/craftagram/issues/58, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAM5Z3KW4NI3BPV2GJK5VKLWJT4LJANCNFSM6AAAAAASIBSDUA . You are receiving this because you are subscribed to this thread.Message ID: @.***>
Here you go:
yii\base\ErrorException: Undefined property: stdClass::$access_token in /chroot/home/lswisced/ls.wisc.edu/vendor/scaramangagency/craftagram/src/services/CraftagramService.php:166 Stack trace:
@joshua-martin have you had a chance to look at this? We have a production site we'd like to fix. Thanks!
@simonkuran Sorry, I hadn't had a chance to look into it until now. Presumably you're still seeing this issue?
Have you previously used this application for a different website? The only way I can replicate this is by trying to use an application that has already been authenticated on one domain on another domain, and even then it doesn't happen all of the time. It might be something to do with the authorisation code already being used (which doesn't appear to be that wide an issue, which would make sense given the auth codes only live for an hour - i.e. https://github.com/espresso-dev/instagram-basic-display-php/issues/14).
Is this a fresh application you have just created? The only thing I can think of that would really help is to go into /vendor/scaramangagency/craftagram/services/CraftagramService
and dd(json_decode($res))
on after curl_close
on line 138 and see what comes back.
@joshua-martin All good! The debugging on line 138 put me on the right track. Turns out there was a "API access deactivated. To reactivate, go to the app dashboard." error that wasn't coming through. I just needed to fix a couple items with my app in the Facebook developer portal.
By changing line 140 from $shortAccessToken = json_decode($res)->access_token;
to $shortAccessToken = json_decode($res)->{'access_token'};
and line 167 from $token = json_decode($res)->access_token;
to $token = json_decode($res)->{'access_token'};
then I was able to get the error to come through with dd(json_decode($res));
So the error was definitely on my end, but it would be great if the plugin could forward this useful error on to me by default. None of my edits were necessary once I resolved the Facebook issue.
If you're testing this, I believe disabling the app in Facebook should trigger this issue.
Thanks for your help!
When Instagram redirects back to the site after I approve the authorization I get a "Undefined property: stdClass::$access_token" error. Do you know what could be causing that?
I'm running Craft v3.6.10 and Craftagram v1.4.4.