Shopify_app gem and Rails?

Hi,

I’m a completely new to both Rails and Shopify, but trying to learn and need some help making a simple start querying some Orders from a basic Rails app.

Where I am at:

So far, I’ve got myself setup as a Shopify Partner, have a Test Store, and can make queries via cURL just fine.

What I want to achieve:

I’m not wanting to make an embedded app for Shopify (at this stage).

Instead, I simply want to be able to authenticate (Oauth), and query some Orders (from my Test store) from within my simple, standalone Rails app.

What I’m confused about:

The ShopifyAPI gem seemed like the natural place to start, at least for my basic requirements, but documentation highly recommends using the shopify_app gem instead.

But, when I read the documentation for the shopify_app gem it seems largely oriented around making an embedded app, which is not what I want right now. Nor, is it clear how to use it for my simplistic purposes.

As such, I’m unsure which it is the best gem for the job, and how to proceed with it.

Any help would be greatly appreciated.

Thanks,

Paul S.

Hi @Paul_Swanson

If you only want to try calling the Shopify API, you can follow these steps:

  1. Create a dev app (dev app).

    1. visit dev dashboard

    2. Create apps:

  2. Get access token: Using the client credentials grant

  3. Call the Shopify API, eg. products - GraphQL Admin

Hi Kyle,

Thanks for you reply.

Like I said, I’ve already got basic token access.

What I’m wanting to do is go a step further, and integrate a Shopify gem into my code to make Oauth and other data work more reliably.

Cheers,

Paul Swanson

Hi @Paul_Swanson

I understand your idea. Shopify provides an official authentication guide and sample code: https://shopify.dev/docs/apps/build/authentication-authorization. If you encounter any issues during a specific step, feel free to continue the discussion here. Additionally, Shopify offers a variety of app templates:Shopify API, libraries, and tools, you can start with these to help you familiarize yourself with the process.

Hello @Paul_Swanson, you can refer this Ruby script that uses shopify_api gem.

Please follow the steps below:

  • Step1: You will need to create the app in the Dev Dashboard.
  • Step2: Go to Versions → set your scopes (like read_products) → Release
  • Step3: Install the app on your store from the app’s Home tab
  • Step4: Grab the Client ID and Secret from Settings
  • Step5: Run the script and enjoy :smiley:
1 Like

Hi @remy727 , that’s the kind of thing I was looking for, thanks!

I’m going to keep this issue open for a little longer, as I’m still hoping to utilise the shopify_app gem for its classes, and other stuff, directly in a Rails app (I’d rather not reinvent the wheel).

But, that script of yours is a good start, cheers. :grin:

@Paul_Swanson, since you don’t need the UI in the app, shopify_api gem is enough.

1 Like

Right.

I was just trying to follow the advice from the ShopifyAPI which says if you’re using it in a Rails app then shopify_app gem is preferred.

So, I’m guessing then that shopify_app gem primarily exists to make embeddable apps with Rails (as opposed to Node)?

If shopify_api provides functional Oauth and queries then that’s all I need at this stage. Plus, I can use that easily enough in any existing Rails apps I might be working on.

Thanks.

I am wondering why do you need Rails app to get data using Shopify API?
Is not Ruby script enough for you?

I don’t need a Rails app just to get Shopify data.

I’m developing a Rails app which needs to get / put data to Shopify, amongst other requirements.

I initially looked into the ShopifyAPI (Ruby) and this is the official advice concerning use with Rails apps. :backhand_index_pointing_down:

But, the script you’ve provided looks definitely enough to get me started, thanks.

Aha, got it.
Can you please check Shopify App Template - Ruby then?

1 Like

Will do.

I had noticed that one earlier, but was still trying to wrap my head around the whole domain; will have a go at that template soon.

Cheers.