shopifex icon indicating copy to clipboard operation
shopifex copied to clipboard

OAuth and webhooks when using Shopify CLI

Open NexPB opened this issue 9 months ago • 4 comments

These days Shopify is pushing the CLI hard esp. when you follow their dev guides. These changes allow you get get going with the CLI more quickly when using shopifex. (PR is in draft as I would like to get some feedback)

Key changes

  • Optional webhook topic config: when using the CLI webhooks are managed out of the box
  • OAuth flow: Shopify assumes the app to have a route at /auth/callback (when using automatically_update_urls_on_dev)

I had trouble with the app not rendering (upon install) after the oauth flow had finished, I assume because it was embedded and required the app bridge redirect flow so I've made changes to account for that.

NexPB avatar Mar 19 '25 11:03 NexPB

Looks really interesting at first glance. I will test it out in my own Shopify apps to see if there are any compatibility issues coming up. What was the rest of your setup in regards to using Shopify CLI alongside Shopifex?

ericdude4 avatar Mar 19 '25 12:03 ericdude4

What was the rest of your setup in regards to using Shopify CLI alongside Shopifex?

My folder structure basically is as seen here https://github.com/NexPB/phx-shopify-app-example Important files are the Shopify cli config files generated by shopify app init:

  • https://github.com/NexPB/phx-shopify-app-example/blob/master/shopify/shopify.app.toml
  • https://github.com/NexPB/phx-shopify-app-example/blob/master/shopify/web/shopify.web.toml <- slightly modified to start a phoenix server

Afterwards I start the my local env using shopify app dev, does some Shopify stuff like setting up a cloudflare proxy and starting the phoenix app. The cli sets certain env vars which make it easy to configure your phoenix app using runtime.exs.

Hope that answers your question.

NexPB avatar Mar 19 '25 13:03 NexPB

That's really interesting! So you have your dev server running with shopify app dev and it takes care of updating the tunnel URLs on your development app and starts the phoenix dev server? This is a lot cleaner than what I've been doing all these years. To be honest I haven't looked at the Shopify CLI much since I figured it wouldn't work with my Phoenix stack.

I will review this more thoroughly soon, but this will definitely justify an update to the readme for this library.

ericdude4 avatar Mar 19 '25 17:03 ericdude4

That's really interesting! So you have your dev server running with shopify app dev and it takes care of updating the tunnel URLs on your development app and starts the phoenix dev server?

Yeah makes things pretty seamless

but this will definitely justify an update to the readme for this library

I'll try adding that to the PR this weekend

NexPB avatar Mar 20 '25 12:03 NexPB

@ericdude4 I've added a section for the Shopify CLI at the end of the README

NexPB avatar Mar 26 '25 13:03 NexPB

There are a few places in the codebase where we mention deprecating things when updating to version 3.x. I wonder if we take this opportunity to release a new 3.x version of shopifex as a release candidate. I happen to be just starting to build a new app with Shopifex, so it would be a great way to test too.

ericdude4 avatar Apr 01 '25 11:04 ericdude4

There are a few places in the codebase where we mention deprecating things when updating to version 3.x. I wonder if we take this opportunity to release a new 3.x version of shopifex as a release candidate. I happen to be just starting to build a new app with Shopifex, so it would be a great way to test too.

I did notice some changes that would benefit a 3.x release such as using some newer http libraries (I'm quite fond of tesla myself) instead of httpoison, I also noticed we pull in the neuron dep for a single graphql call I think this dep could ship with it's own simple client.

NexPB avatar Apr 06 '25 05:04 NexPB

There are a few places in the codebase where we mention deprecating things when updating to version 3.x. I wonder if we take this opportunity to release a new 3.x version of shopifex as a release candidate. I happen to be just starting to build a new app with Shopifex, so it would be a great way to test too.

I did notice some changes that would benefit a 3.x release such as using some newer http libraries (I'm quite fond of tesla myself) instead of httpoison, I also noticed we pull in the neuron dep for a single graphql call I think this dep could ship with it's own simple client.

@NexPB I think a 3.x release is a fantastic idea. I really appreciate your willingness to help with this!

I wonder if we create a Shopifex.HTTPClientBehaviour (get, post, delete, etc) then ship the library with a tesla implementation Shopifex.HTTPClient.Tesla. This would allow it to be mocked with mox more easily also allow someone to create another implementation with their own HTTP client library-of-choice. Have you seen this pattern in practice before?

Do you have discord? Maybe we can continue the conversation there?

ericdude4 avatar Apr 07 '25 12:04 ericdude4

Do you have discord?

Yeah, my discord username is nexpb

NexPB avatar Apr 08 '25 00:04 NexPB

Following these changes. @NexPB your sample repo is quite helpful!

Has anyone been using things with the Phoenix 1.8 RCs?

jeffreyguenther avatar Jul 16 '25 22:07 jeffreyguenther

Has anyone been using things with the Phoenix 1.8 RCs?

Have only been using this with 1.7

NexPB avatar Aug 18 '25 00:08 NexPB

What's the state of this? Will it get merged?

pepicrft avatar Sep 21 '25 16:09 pepicrft