Kyon147 / laravel-shopify

A full-featured Laravel package for aiding in Shopify App development
MIT License
363 stars 107 forks source link

Infinite Loop on app page with fresh installation (19.1) Shopify AppBridge [Solved] #215

Closed faridmovsumov closed 1 year ago

faridmovsumov commented 1 year ago

I have a fresh installation (19.1), and I am facing an infinite loop between the token and home endpoints.

https://kuzey.eu-1.sharedwithexpose.com/authenticate/token?shop=azerify.myshopify.com&target=%2F%3Fembedded%3D1%26host%3DYWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvYXplcmlmeQ%26token%3DeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczpcL1wvYXplcmlmeS5teXNob3BpZnkuY29tXC9hZG1pbiIsImRlc3QiOiJodHRwczpcL1wvYXplcmlmeS5teXNob3BpZnkuY29tIiwiYXVkIjoiMDc0ZTZlMTdjNzAwZTliMDU3OGU3NmM0YjI4NGNmNzkiLCJzdWIiOiI3MzA4MDYwMjY4MiIsImV4cCI6MTY5NjE4NjA4MywibmJmIjoxNjk2MTg2MDIzLCJpYXQiOjE2OTYxODYwMjMsImp0aSI6IjFmYjY0NTE4LTUzNTctNGQ5Ny1hY2QxLWE0YjVmZGE3ZTkyMiIsInNpZCI6IjdhNGI3NmQyMGFkYzg1N2U1NWM3NWYzNzk0NGM5OWE5OTc2MjUxNDQ4M2JjMTgyZTMxZTBiNGYxZTcxYzZlMTcifQ.cjJU57IM47DuXrbTxGe6P534sAnsoXwP0lAYGDO9f-Y&host=YWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvYXplcmlmeQ

https://kuzey.eu-1.sharedwithexpose.com/?embedded=1&host=YWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvYXplcmlmeQ&shop=azerify.myshopify.com&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczpcL1wvYXplcmlmeS5teXNob3BpZnkuY29tXC9hZG1pbiIsImRlc3QiOiJodHRwczpcL1wvYXplcmlmeS5teXNob3BpZnkuY29tIiwiYXVkIjoiMDc0ZTZlMTdjNzAwZTliMDU3OGU3NmM0YjI4NGNmNzkiLCJzdWIiOiI3MzA4MDYwMjY4MiIsImV4cCI6MTY5NjE4NjA4MywibmJmIjoxNjk2MTg2MDIzLCJpYXQiOjE2OTYxODYwMjMsImp0aSI6IjFmYjY0NTE4LTUzNTctNGQ5Ny1hY2QxLWE0YjVmZGE3ZTkyMiIsInNpZCI6IjdhNGI3NmQyMGFkYzg1N2U1NWM3NWYzNzk0NGM5OWE5OTc2MjUxNDQ4M2JjMTgyZTMxZTBiNGYxZTcxYzZlMTcifQ.cjJU57IM47DuXrbTxGe6P534sAnsoXwP0lAYGDO9f-Y

I have a fresh Laravel installation, and I have a fresh installation of the library.

image

You can see below the screenshot of what it looks like.

image

Some var_dumps in the case can be helpful.

image

Additionally, I am running Laravel on Mac with Laravel Sail and using expose.dev service for https.

Also, I added some debugging to token.blade.php, and the redirect URL has a host parameter twice. It feels like something is wrong there.

image

https://kuzey.eu-1.sharedwithexpose.com/authenticate/token?shop=azerify.myshopify.com&target=/?embedded=1&host=YWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvYXplcmlmeQ&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczpcL1wvYXplcmlmeS5teXNob3BpZnkuY29tXC9hZG1pbiIsImRlc3QiOiJodHRwczpcL1wvYXplcmlmeS5teXNob3BpZnkuY29tIiwiYXVkIjoiMDc0ZTZlMTdjNzAwZTliMDU3OGU3NmM0YjI4NGNmNzkiLCJzdWIiOiI3MzA4MDYwMjY4MiIsImV4cCI6MTY5NjE4NTQ1MSwibmJmIjoxNjk2MTg1MzkxLCJpYXQiOjE2OTYxODUzOTEsImp0aSI6ImJhODEyNjcyLWIzZGUtNGFjNy1iYzg4LTY1N2E0YmFlZWJkMyIsInNpZCI6IjdhNGI3NmQyMGFkYzg1N2U1NWM3NWYzNzk0NGM5OWE5OTc2MjUxNDQ4M2JjMTgyZTMxZTBiNGYxZTcxYzZlMTcifQ.VkfMFSnHMiBrVXE7IEXvDOuIlBKUOYGjvLTypPtAox4&host=YWRtaW4uc2hvcGlmeS5jb20vc3RvcmUvYXplcmlmeQ

Kyon147 commented 1 year ago

@faridmovsumov do you get this all the time?

I've seen this issue before with those using blade templates, that sometimes, the redirect URL is set at /token so a infinite loop happens.

faridmovsumov commented 1 year ago

@Kyon147 Yes, all the time. I tried to debug to understand the reason but no success so far. Even re-installing the app didn't solve the issue.

faridmovsumov commented 1 year ago

I am doing some debugging, so I will add my findings here.

Exception is being thrown inside VerifyShopify Middleware

image
faridmovsumov commented 1 year ago
image

Seems like token is expired. Expiration date set to now.

image
Kyon147 commented 1 year ago

Token's only live for 1 minute, but the auth/token route should ask again for a new token each time to get whatever one is valid.

faridmovsumov commented 1 year ago

Ok, I finally found the reason for this weird bug. It was occurring because the time settings of my machine somehow weren't matching with the server's time settings. I simply set it on Mac to be set automatically and the problem is fixed.

image

Thanks for support @Kyon147

Kyon147 commented 1 year ago

@faridmovsumov I'm glad you found the issue. I've seen the time sync issue pop up a couple times actually thinking back.

I might add a common issues page to the wiki and add this on to it.